Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Dynamic JQuery Objects Calling to Function


ZakAltF4 - 5:14 pm on Jan 13, 2012 (gmt 0)


Hello All,

I have a, what may be simple for someone out there, question ... I have a JQuery script that is dynamically creating elements on a page. Well I have a function ... Lets say:


<script>
$("#Go").click(function() {
alert ('!');
});
</script>


I have the following dynamically created objects:

<a href="#" id="Go">Click 1</a>
<a href="#" id="Go">Click 2</a>
<a href="#" id="Go">Click 3</a>


Now here is the tricky part for me. In JavaScript I would have just assigned each *a* tag like such and called the function accordingly:


<script>
function CallAlert(id){
alert ('ID is ' + id);
}
</script>

<a href="#" OnClick"CallAlert(1)">Click 1</a>
<a href="#" OnClick"CallAlert(2)>Click 2</a>
<a href="#" OnClick"CallAlert(3)>Click 3</a>


With Javascript I can pass the 1, 2 and 3 to the function via identifiers ... I know there must be a way to do this with JQuery?

If you can mimic the JavaScript I created with JQuery it would be greatly appreciated. I know I am missing something simple, I just don't know what ... Thanks!

-- Zak


Thread source:: http://www.webmasterworld.com/javascript/4406594.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com