Solve IE7 using jQuery dynamic operation NAME problem

Problem: The NAME property of the jQuery dynamic operation page element cannot be used in IE7.

There is a problem in the project, and some customers can occasionally, and the rear tens will not be able to get the data value of the front desk.

The development and test environment can not be reproduced. The pothole is here. If you can’t reproduce it, you can’t debug it, you can’t know that there will be such a problem.

Think about the only difference between the customer’s environment, only the JS cache problem, then add a current time parameter to the place referenced by all JS files, and the problem still exists.

The version of this is IE8, so I have never thought of a version compatibility problem. In the case of jQuery, jQeruy’s appearance is not known as a compatibility problem that solves the browser.

The problem of damn problems and real version issues. Because some pages need to use IE8 compatibility mode, the compatibility model is actually as compatible, isn’t it compatible with IE7?

Then use DEMO to test locally.

$ ("# INPUT"). Attr (" Name "," MyName "); Alert (" Name: "+ $" # INPUT "). Attr (" Name ") +" *** HTML: "+ $" "# div"). html ())
OK! IE8 compatibility mode:

?? Why

$ (“# INPUT”). Attr (“Name”) 解决IE7中使用jQuery动态操作name问题 taken It is a modified value, and

$ (“# div”). Html ()

taken NameOr is it the original value? ?

F12 View the generated HTML

解决IE7中使用jQuery动态操作name问题 What is the SubmitName? Obviously Name has not changed. Submitname should be the value of SubmitName directly read when jQuery is generated and then read Name.

Why is $ ("# div"). There is no submitname in the value of html () ? ? I also don’t know how the HTML method in jQuery is achieved ~~ The implementation method is similar to:


// Alert ("NAME:" + $ ("# INPUT"). Attr ("Name") + "* ** HTML: "+ $ (" # div "). HTML ()); $ (" # INPUT "). Attr (" Name "," MyName "); $ (" # Div2 "). HTML ($ ($). "#div"). HTML ()); var nameval = $ ("# div2"). Find ("INPUT [Name = 'MyName'). Val (); Alert (NameVal);

so that IE8 and Google Chrome normal value, but did not get value in IE8 compatibility mode. [Don’t ask why it is necessary to value this value, this is Demo ‘similar to’ realization, and is a framework]
1. Direct Modify NAME with jQuery and then access Name is OK, although the middle is generated in SubmitName.
2. You can first
$ ("# div2"). HTML ($ ("# div"). Html ()); and then modify. Attr ("Name "," myname "); 3. Can directly spliced ​​HTML.
("# div"). HTML ("

The last Baidu is under, IE7 cannot be used to dynamically create and modify the JS dynamic creation and modification. Name value.

The above is a small-knit to give you a solution to the use of jQuery dynamic operation NAME issues in IE7, I hope that everyone has anything. If you have questions, please leave a message, the small package will reply to everyone in time. Thank you very much for your support of Tumi Cloud Website!

© Copyright Notice
Just support it if you like
comment Grab the couch

Please log in to comment