Jquery method to determine whether an element is clicked: after the click event occurs, change the value of the flag bit and record the click status, thereby achieving the purpose of determining whether the element is clicked, such as [$('#test') .click(function(){isClick = true;});].
The operating environment of this tutorial: windows7 system, jquery3.2.1 version. This method is suitable for all brands of computers.
Jquery method to determine whether an element is clicked:
(Learning video sharing: javascript video tutorial)
Thinking:
After the click event occurs, the value of the flag bit is changed and the click status is recorded, thereby achieving the purpose of determining whether the element has been clicked.
1 function(){ 2 var isClick = false; 3 $('#test').click(function(){isClick = true;}); 4 $('#show').click(function(){alert(isClick);}) 5 }
Add and delete classes: $('#id').addClass(), $('#id').removeClass()
Get the setting element value: $('.class' ).text(), $('#id').html(), $('.class').val()
Add attributes or modify attribute values: $('#id'). attr({'style':'display:none'})
toggle()
toggle() method switches the visible state of an element. Hides the selected elements if they are visible, and shows them if the selected elements are hidden.
Grammar:
$(selector).toggle(speed,callback,switch)
The parameters are as follows:
The above is the detailed content of How to determine whether an element is clicked in jquery. For more information, please follow other related articles on the PHP Chinese website!