In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to solve the problem of jquery. Attr failure". In daily operation, I believe many people have doubts about how to solve the problem of jquery. Attr failure. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "how to solve the problem of jquery. Attr failure"! Next, please follow the editor to study!
The solution to the failure of jquery .attr: 1, create a HTML sample file; 2, operate checkbox;3 through jquery and replace attr with prop.
This article operating environment: windows7 system, jquery1.2.6 version, DELL G3 computer
What if jquery. Attr fails?
Solve the problem of multiple use failure of jquery attr
Today, jq's attr method is used to do an all-to-all function, but for the first time in real use, it is possible to achieve all-select and none-select functions. However,
A few more times, the effect of checking will disappear!
Take a look at the code first:
Jquery operation checkbox method / / Select all function selectAll () {/ / method 1: $("input [name = 'bjjb']") .attr ("checked", true) / / method 2: / * * $("input [name = 'bjjb']") .each (function () {$(this) .attr ("checked", true);}); * / / get the value of checkbox and the text $("# checked") .html ("") $("# checkedText"). Html ("); $(" input [name = 'bjjb']: checked ") .each (function () {$(" # checked "). Append ($(this). Val () +", ") / / Note that the text must be labeled with an element such as span or next will not get a value of $("# checkedText") .append ($(this). Next (). Text () + ",);}) } / / deselect all function selectNone () {/ / method 1: $("input [name = 'bjjb']") .removeAttr ("checked") / / method 2: / * $("input [name = 'bjjb']") .each (function () {$(this) .attr ("checked", false);}); * / / get the value of checkbox and the text $("# checked") .html ("") $("# checkedText"). Html ("); $(" input [name = 'bjjb']: checked ") .each (function () {$(" # checked "). Append ($(this). Val () +", ") / / Note that the text must be labeled with an element such as span or next will not get a value of $("# checkedText") .append ($(this). Next (). Text () + ",);}) } / / invert function selectInvert () {$("input [name = 'bjjb']") .each (function (index,item) {if ($(this) .attr ("checked")) {$(this) .removeAttr ("checked") } else {$(this) .attr ("checked", true);}}) } option 1, option 2, option 3, option 4, item 5
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.