Click event cannot be triggered, div access value

Source: Internet
Author: User

1. If a problem occurs in the project, the click of the button cannot be triggered. If you click the button, the breakpoint does not go to the click. That is, if the click method is not triggered, You need to bind the event.

$ (". Successnum"). Each (function (I ){
$ (This). BIND ("click", sub );
});

Code explanation:

Traverse all the elements whose class names are. successnum and add events to them one by one. Sub is the method called when the click is triggered.

2. Div is a block element that automatically occupies a row when displayed. display: block ;. Div has no value attribute, but if you need Div to access the value, you can set the title of the DIV and obtain the title attribute value of the div.

For example, in an Ajax request:

For (VAR I = 0; I <data. length; I ++) {// ID of the data stored by the title Attribute Value

$ ("# Selectable"). append ("<li class = 'ui-state-default'>" +
"<Div class = 'adaptername' Title = '" + data [I]. adapter_id + "'>" + data [I]. adapter_name + "</div>" +
"<Div class = 'successnum' Title = '1'> success count:" + data [I]. ssize + "</div>" +
"<Div class = 'errornum' Title = '0'> failure count:" + data [I]. fsize + "</div> </LI> ");

}

// Add a binding event.

$ (". Successnum,. errornum"). BIND ("click", sub );

3. Obtain the title attribute accessed in the div.

Function Sub (){

VaR titlevalue = $ (this). SRC ("title ");

}

4. The real cause of the error.

Reference the plug-in jqueryui, selectedtable, which disables the mouse click event. The plug-in does not have much effect, so just remove it.

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.