Difference between ‘return false;’ and ‘e.preventDefault();
Difference between ‘return false;’ and ‘e.preventDefault(); `e.preventDefault()` which will prevent the default event from occurring, but will continue the event flow (ie., next line of code in the function) return false will always had
How to close the div popup/any Element while clicking outside of the popup
How to close the div popup/any Element while clicking outside of the popup JQUERY $(document).mouseup(function(e) { var container = $("#divPatientDetail"); if (container.has(e.target).length === 0) { container.hide(); } }); Explanation: var container = $("#divPatientDetail"); -- Assigning
How to check the div is visible/Hidden
How to check the div(any element) is visible/Hidden HTML : <div id="divPatientDetail"></div> JQuery : if ($("#divPatientDetail").is(":hidden")) {} if ($("#divPatientAcuityDetails").is(":visible")) {} Explanation : Codition will check whether "divPatientDetail" div is hidden or visible
How to split the attribut “class” name in the html element
How to split the attribute "class" name in the html element HTML : <div id="divUserDetails" class="red"> JQEURY : $(document).on("click", "#divUserDetails", function() { var userColor = $(this).attr('class') == null ? "No User Color Found" : $(this).attr('class');
How to get the top and left positon of clicked td/div
How to get the top and left positon of clicked td/div Jquery $(document).on("click", "#tbUserDetails", function() { var getclickTop = $(this).offset().top; var getclickLeft = $(this).offset().left; } Explanation: .on method is used for dynamically created table using
removeAttr() Method
.removeAttr() Remove an attribute from each element in the set of matched elements. HTML : <table border="1"> <tr><td>This is first table</td></tr> </table> JQUERY: $(document).ready(function() { $("table").removeAttr("border"); }); OUTPUT DOM : <table> <tr><td>This is first table</td></tr>
attr() Method
attr() : The attr() method sets or returns attribute values of selected elements. Getting attribute JQUERY : 1 alert($("#img1").attr("href")); From above JQ, the message box will show the link of img1(which element having id as
clone() Method
clone() Create a deep copy of the set of matched elements. We can use clone copy in to two ways,clone()/clone(true).It also support a boolean parameter to indicate whether need to copy the event