Reply
Need to "Get Triggering Object"
Old 03-31-2008, 01:07 AM Need to "Get Triggering Object"
RadGH's Avatar
Experienced Talker

Posts: 48
Name: Radley
Let's say I have dynamically rendering DIV's that contain one H as the menubar, and a SPAN as the contents. When clicking the H, the SPAN will appear (Display: "") - and clicking it again will hide it (Display: none).

Hopefully this has a simple answer, I tried searching google but I don't think my terms are returning what I'm looking for... (Like [get object triggered javascript] or [triggering object javascript] etc)

I found a few examples online but they all involve preset id's or arrays which in theory would work but I would find the "Triggering Object" would be much more useful for many things.

Heres one example that has no demonstration, and I can't seem to get it to work.

Heres another example that seemed to be more useful, but is not independent of each other.

(Edit) I had high hopes for this example, but it doesn't seem to work in Firefox. I'm thinking the event.srcObject does not work in Firefox... Its working in IE!


And heres a quick snippet that, if you can get it to work or tell me what I'm looking for, I will greatly appreciate. The goal is not to use object ID's and not to affect other H3's (Only ones included by the .collapsible)

PHP Code:
<style type="text/css">
    .
collapsible {background-color#666; padding: 0px; border: 3px #AAA double;}
    
.collapsible h3 {color#FC0; font-weight: bold; background-color: #888; margin: 0px; padding: 2px 6px;}
    
.collapsible h3:hover {background-color#AAA; cursor:;}
    
.collapsible p {color#FFF; margin: 0px; padding: 5px 10px 10px 10px;}
</style>

<
div style="width: 300px; margin: 0 auto;">
    <
div class="collapsible">
        <
h3 onclick="collapse()">Headline</h3>
        <
p>Paragraph Paragraph Paragraph Paragraph Paragraph Paragraph</p>
    </
div>
    <
hr width="200">
    <
div class="collapsible">
        <
h3 onclick="collapse()">Headline 2</h3>
        <
p style="display: none;">This should be hidden by default</p>
    </
div>
</
div

Last edited by RadGH : 03-31-2008 at 01:15 AM.
RadGH is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 03-31-2008, 05:29 AM Re: Need to "Get Triggering Object"
chrishirst's Avatar
Super Moderator

Posts: 13,481
Location: Blackpool. UK
Not without some unique IDs or names

srcElement is not supported by Mozilla/Firefox, use "target" which of course is not supported by IE
http://www.quirksmode.org/dom/w3c_events.html#t03

http://www.w3schools.com/jsref/jsref_onmousedown.asp

but you will HAVE to use a unique reference to the element otherwise how WILL the script "know" which element to show or hide?

You couldn't reference it as a child <p> of "collapsible" because there are two of them in your example.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Need to "Get Triggering Object"
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12560 seconds with 12 queries