Currently several borrowing jquery Select click Element to get the current click Element Information,
$ (document). Click (function (e) {//) to trigger this event at any point in the page ( e.target). attr ("id"); E.target = clicked Target})
This method is needed to obtain the current Click Element information such as id,value, such as information, can not be accurately located, obtain, therefore need this, and the current meaning
Borrow this to get the current element information
HTML code
<ul> <li class= "A" id= "ongoing" > In progress </li> <li id= "About_to_begin" > About to start </li> <li id= "Past_activities" > Past Events </li></ul>
JS Code
$ (document). Ready (function () {$ ("Li"). Click (function () {//Click to pass the tag, ID, class name, etc.//alert ($ (this). attr ("id"))// Here you can get the ID of the clicked element, take its value and alert ($ (this) with the attr () method . HTML ()) //Get the content of the clicked element
After you get the content, you can use the Ajax method to exchange data with the backend, and then interact with var code = $ (This). attr ("id")//console.log (code) $ ("#a div"). Remove (); With the Click event to get the element while deleting the HTML page part of the content can also add elements of the method to add the element $ ("#b div"). Remove (); $ ("#c div"). Remove (); }) ;
jquery Select click Element to get current click Element information