jquery - How do i call the same function with different element id tags? -


I am a lot new for jquery and there is a problem calling more than one instance of the function.

I have a function

  $ ('# open_dialog'). Click (function () {$ ("# dialog"). Dialog ("open"); return false;});  

To call this function I have a href link with the name tag name of open_dialog, of course it works very well if it is the only link on the page which refers to the function Does (one relation to one) However, I want that (a lot of relationships).

I have a table of 25 records and each of my records is required for a link which will call the open_dialog function I know that not all IDs can be called Open_dialog because they have to be unique So, how do I use the function when crossing that value, from which one of my 25 records is giving immediate function.

The way my records are dynamic, $ ('#open_dialog, open_dialog2, open_dialog3, ...') is not practical.

Thanks for watching my post

Instead of using unique ID If you can use a class on your item, just use

  $ ('. Classname'). // 'this' will refer to the anchor which was clicked on $ ("# dialog"). Dialog ("open"); Return back;});  

Also, you can add another attribute to the anchor, i.e.

  & lt; A href = "#" class = "classname" record = "14" & gt; Record 14 & lt; / A & gt;  

Then inside your function you can

  var record = $ (this) .attr ("record");  

Record will now include 14.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -