javascript - Remove class on radio's that are not checked -


इसलिए मुझे यह कोड है

  & lt; ul id = "id_priori" & gt; & Lt; li & gt; & Lt; label = "id_priori_0" & gt; के लिए & Lt; इनपुट आईडी = "id_priori_0" नाम = "प्राथमिकता" प्रकार = "रेडियो" & gt; होल & lt; / लेबल & gt; & Lt; / li & gt; & Lt; / ul & gt;  

और यह कोड

  $ ("# id_tipo")। पर ('क्लिक', 'ली', फ़ंक्शन () {var self = $ (यह), रेडियो = self.find (": रेडियो") [0]; रेडियो। चेक किया गया! रेडियो! चेक किया गया; self.toggleClass ('on', radio.checked);}) .find (": रेडियो" ) .each (फ़ंक्शन () {$ (यह) .closest ('li')। ToggleClass ('पर', this.checked);});  

मुझे क्या चाहिए जो सभी लेबल, जिनकी रेडियो की जांच नहीं की जाती है, को छोड़ना है?

  $ (": रेडियो: नहीं (चेक)")। प्रत्येक (फ़ंक्शन () {$ (this) .clostest ('li')। RemoveClass ('पर');}) ;  

वैसे भी, यह मानते हुए कि सभी रेडियो जुड़े हुए हैं, और हमेशा एक ही चेक किया जाता है, पूरे कोड सरल हो सकता है:

  $ ("# id_priori" ) (पर क्लिक करें, 'ली', फ़ंक्शन () {$ (यह) .फंड (': रेडियो')। प्रोप ('चेक किया', सही); $ (यह) .addClass ('ऑन')। भाई बहन ()। RemoveClass ('पर');});  

इस पर एक नज़र डालें। हम इस बिंदु से काम कर सकते हैं


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

c# - Create dynamic LINQ query expression at runtime which translates into a parameterized SQL query for nullable types -

cmake - cpack generates RPMs with %files entries that conflict with the RPM spec. How to fix? -