jquery attr A solution to the problem of & (macro) notation in SRC _jquery

Source: Internet
Author: User
Problem Description:

The HTML code is as follows:

<iframe src= "http://www.jb51.net" id= "Addorupdateiframe" style= "width:870px;height:450px" border= "0" scrolling= "Yes" ></iframe>

I set the src attribute of the IFRAME using the attr method of jquery

$ ("#addOrUpdateIframe"). attr ("src", "http://blog.jb51.net/search.aspx?key=400");/clickable link View effect note number of pages (show first page data)

No problem, I got the result I wanted, but the following address dropped the arguments behind the key (the red font parameter was not taken)

$ ("#addOrUpdateIframe"). attr ("src", "http://blog.jb51.net/search.aspx?key=400&page=2");/clickable link to view effect Note Number of pages (show second page data)


Depressed, feeling very strange, with Firebug looked at the modified value, the problem found, jquery to the above address to become:

http://blog.jb51.net/search.aspx?key=400&page=2//clickable Link View Effect Note page (show first page data)

In the middle of a depression ......

Looking for a long time also did not find if the problem, how he will address the & to change to & it? I don't know what I'm doing.

Problem Solving Method:

is inadvertently put

$ ("#addOrUpdateIframe"). attr ("src", "http://blog.jb51.net/search.aspx?key=400&page=2");/clickable link to view effect Note Number of pages (show first page data)

Change into

$ ("#addOrUpdateIframe"). attr ("src", ' http://blog.jb51.net/search.aspx?key=400&page=2 ');//clickable link to view effect Note Number of pages (show second page data)

Notice the gray background, change the double quotes into single quotes, and solve the problem.

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.