Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Javascript interacting with js generated code
Old 04-07-2009, 10:27 AM Javascript interacting with js generated code
Average Talker

Posts: 15
Trades: 0
Hey guys,

This is a fairly rookie question but I've not been able to find any information on it (mostly due to being clueless as to what keywords I'd need to search).

My issue is, put simply that if I generated a few div tags with an id or class attached and output it to a page I then want to be able to interact with those with javascript.

For example, I have a script that outputs this...

Code:
<div id="box1"><img src="image1.jpg" alt="" /></div>
<div id="box2"><img src="image2.jpg" alt="" /></div>
<div id="box3"><img src="image3.jpg" alt="" /></div>
<div id="box4"><img src="image4.jpg" alt="" /></div>
Now I want to use jQuery to fade out the opacity of box2, box3 and box4 but when I use the fade function in jQuery nothing happens and I get an error message that says it can't find box2, box3 or box4.

The question is, how can (if there is a way) you get javascript to interact with code that it has output into a page itself, or am I really off the scent and going about it completely the wrong way.

Hope someone can shed some light on this for me!

Cheers,

Leonard
Gentleman_ is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-07-2009, 11:19 AM Re: Javascript interacting with js generated code
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
There is no problem attaching events to, or interacting with content that you have generated, but you need to do it after the content has been generated, or your scripts won't be able to find it.
__________________
Join me on
Please login or register to view this content. Registration is FREE

Last edited by wayfarer07; 04-07-2009 at 11:20 AM..
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 04-07-2009, 12:04 PM Re: Javascript interacting with js generated code
Average Talker

Posts: 15
Trades: 0
Cheers!

I'm a bit embarrassed that I completely missed that one, I was convinced that was something I'd tested out before but trying it now I realised that its most likely just a thought that I never actually made it out of the dusty corner of my brain

Thanks wayfarer07

- Leonard
Gentleman_ is offline
Reply With Quote
View Public Profile
 
Old 04-07-2009, 12:25 PM Re: Javascript interacting with js generated code
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
It's actually a very common mistake, you shouldn't feel bad at all.
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Reply     « Reply to Javascript interacting with js generated code
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.80065 seconds with 12 queries