javascript - using attr of the value of child element in a list to change css of div class -
I am preparing the ranking bar, I have 9 times, though I want the height of the bar at 0 And the times are the longest in 8 I use the value of the option of choosing to manipulate my jquery selector to change the CSS style of the bar. Below is my code.
css:
.rating-c .br-widget {height: 60px; Display: Inline; } .teaching-c. BR-Widget A {display: inline; Width: 20px; Height: 60px; Swim left; Background-color: #FFFFFF; Margin: 2px; Text-decoration: None; Font-size: 16px; Font-weight: 400; Line-height: 2.2; Text align: center; Color: # 444444; Border: thin concrete # B6B6B6; } .rating-c .br-widget a.br- active, .rating-c .br-widget a.br-selected {background color: # 59a6d6; White color; }
html:
& lt; Div class = "rating-c" & gt; & Lt; Label class = "rating label" & gt; & Lt; Select ID = "Rating-C" name = "Rating" & gt; & Lt; Option value = "" & gt; & Lt; / Options & gt; & Lt; Option value = "1" & gt; 4 & lt; / Options & gt; & Lt; Option value = "2" & gt; 3 & lt; / Options & gt; & Lt; Option value = "3" & gt; 2 & lt; / Options & gt; & Lt; Option value = "4" & gt; 1 & lt; / Options & gt; & Lt; Option value = "5" & gt; 0 & lt; / Options & gt; & Lt; Option value = "6" & gt; 1 & lt; / Options & gt; & Lt; Option value = "7" & gt; 2 & lt; / Options & gt; & Lt; Option value = "8" & gt; 3 & lt; / Options & gt; & Lt; Option value = "9" & gt; 4 & lt; / Options & gt; & Lt; / Select & gt; Price & lt; / Labels & gt; & Lt; / Div & gt; Javascript: $ ('Rating-c. BR-widget one selection [name = rating]'). Each (function ($ (this) .attr ("value") === "2") {$ ("rating-c"). CSS ("height", "55px");} ($ (This) atter ("value") === "3") {$ ("rating-c. BR-widget A"). CSS ("height", "50px");}});
It does not work, anyone can help Thanks. Please help
Which @ stirlingteacher said, use it, use it this .value
and parseInt
...
if (parseInt (this.value) === 2) {$ ("some"). CSS ("key", "value"); };
First, parseInt
converts the value into a number, which means your special comparison is more important.
Second, we use the value property, this.value
and not the attribute $ (this) .val ()
Retrieves that, instead of the value attribute, which you were previously doing.
Comments
Post a Comment