jquery Select click Element to get current click Element information

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.