html - jQuery syntax question (getting the ID of a link) -
I have a series of links, each with my own ID:
Instead of writing a series of statements:
$ (document) .ready (function () {$ ("a.about") Clicks (Function (event) {$ ("# content"). Load ("/ data.html #about");}); $ ("a.call-us"). ("#content"). Load ( "/ Data.html # call-us");});});
Is there a way to clarify the fact that when I click on the link from class "ajax", I get my #ID
Drag from code> .data.html , and data.html
with id ID #ID
?
(I think right now this class does not specify, but let's just say I have 5 anchors like
This will definitely make the code that was easy to maintain No input will be magnificent.
Yes, very easily:
$ (Document) .ready (function () {$ ("a.ajax") load (click "/ data.html #" + this.id) (function (e) {$ ("# content") E. PreventDefault ();})}};
Comments
Post a Comment