Trial problems of single and double quotes in jquery

Source: Internet
Author: User

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

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.