I was wondering if it is possible to see a group of links within the jQuery class, and when one of those links That link will be loaded in the src iframe of that link.
I think that something like this will
$ (function () {$ ('.link_group a') .on ('click', function () {$ ('Iframe # frameID'). Attr ('src', $ (this) .attr);});}); Edit - My jQuery now looks like this
$ (function () {$ ('.link_group a'). ('Click ', Function () {$ (' iframe # frameID '). Attr (' src ', $ (this) .prop (' href '));});}); HTML
& lt; Div class = "link_group" & gt; & Lt; A href = "link 1. asp" & gt; Link 1 & lt; / A & gt; & Lt; A href = "link 2.asp" & gt; Link 2 & lt; / A & gt; & Lt; A href = "link 3. asp" & gt; Link 3 & lt; / A & gt; & Lt; A href = "link 4.asp" & gt; Link 4 & lt; / A & gt; & Lt; / Div & gt; But this is definitely not working ..
Should anyone do it properly?
You have to pass a parameter for the attr () method, and this Also choose which attribute: $ (this) .attr ('href') or, more recently in jQuery:
$ (this) .prop ('href'); In addition, a id is unique within the document, so that unless you use the same script in other pages and use that code On other element types, specifying iframe is inaccurate, and potentially slows down your selector.
Comments
Post a Comment