Monday 15 April 2013

javascript - Getting the name of a hyperlink when it's clicked using jQuery -


Is there a way to get hyperlink names using jQuery? I have the following code, I need some jQuery direction:

  & lt; A href = "#" id = "imageClick" name = '& lt;% # Eval ("fileName1")%> '& Gt; & Lt; Asp: image id = "myImage" name = '& lt;% # Eval ("fileName1")%> 'Runat = "server" imageUrl =' & lt;% # '~ / Image / "+ Eval (" filename ")%> & gt; & gt; & gt; & lt; / a & gt;   

Actually I would like to return the value of & lt;% # Eval ("fileName1")%> .

Thanks.

EDIT: To be more clear, I have a popup page that contains a list view that contains images and radio buttons, if you click on the radio button, then get the value of that specific choice Should stop popup I am giving value back to the value of the value. So I have what I have:

  $ (document) .ready (function () {$ ("# form1"). Function () {var val = ""; if (val:) if (val! = "$ {'Input: radio [name = myRadio]: check'). Val ()) val = $ ('input : Radio [name = myRadio]: checked '') {$ (Window.opener.document) .find ('# txtlogos'). Val (val); // close window window.close ();}}}; });   

When I click on one of the radio buttons then it works fine but now they've added one more requirement, if they click on the images, So they Inam want (obviously without obstructing the performance of radio buttons).

You just use this.name inside your click handler Can access. Here's the DOM element (jquery is not needed to retrieve the element attribute value), so use the name attribute directly to the element.

  $ ('#imageClick'). Click (function () {warning (this.name);});   

edit

Form changes will not start if you click on an image; Contrary to input, selection, taxresa etc. You need to trigger a formula shift on image click event (click to trigger the occurrence of a form change to simulate a radio button).

Bind one click handler to add your images:

  $ ('yourimageselector') Click (function () {$ (this) .toggleClass ('CheckedImage'); // Add a class on the first click and then click on the class to remove it, it has been closed. If you do not want to turn off the functionality then it is called : // $ (this) .addClass ('checkedImage'); // or if this is only class then this.className = 'check image' class list is still available on all browsers $ ('Yourform'). Change (); // As this image is used, the trigger form changes the event so that you can change the form of your own form of the event (input, selection, texture etc. only) Change will begin).});   

and in your form:

  $ ("# form1"). Change (function () {var imgNames = $ ('. CheckedImage') .map (function () {this.name;} return) .get (); // You will find all image names in an array. // If it Just do an image ($ ('CzechImage'). Length & gt; $) $ ('Checked I') [0] .name, // code is as follows);   



No comments:

Post a Comment