In JavaScript, we basically do not divide the single double quotation marks, so there are a lot of colleagues who have learned JS will be JS to see jquery, the reason is that jquery is a library of JS, then you hit the wrong special. jquery is also a single double quotation mark. Today I'll share some of the categories I've distinguished so far:
1. Get elements with double quotes This should all be remembered, jquery gets the element node ($ ("element selector"))
2. Adding or modifying the contents of an element using the HTML () method must be in single quotation marks
eg
Html:<p>hellow wrold</p>
<button class= "BTN2" > Click </button><br>
jquery:$ (function () {
$ (". Btn2"). Click (function () {
$ ("P"). html ("<a href=" www.baidu.com ">baidu</a>");
});
});
Results:
The fault of the newspaper even you can not believe, I was also looking for a long time, and then did not intend to change the double quotation marks into single quotation marks just fine.
3. Use InsertAfter (), InsertBefore (), append (), prepend (), before (), after () must use single quotation marks, some documents on the Web may or double quotes, in fact, there is a problem.
Can summarize the general situation is the use of double quotes, but there are elements to add, delete the use of single quotation marks
Trial problems of single and double quotes in jquery