여기 내가 가진 것입니다. 값을 올바르게 읽지 않습니다.
http://jsfiddle.net/neowot/7o87wrsy/
HTML :
<a class="InterestLink">Click me</a>
<div id="InterestExpander">
<div id="InterestExpanderX">
×
</div>
<br><br>
General Rating:
<span class="RatingGeneralNumber">80%</span>
</div>
CSS :
<a class="InterestLink">Click me</a>
<div id="InterestExpander">
<div id="InterestExpanderX">
×
</div>
<br><br>
General Rating:
<span class="RatingGeneralNumber">80%</span>
</div>
jQuery :
$('.InterestLink').click(function() {
$('#InterestExpander').fadeIn(450);
if (parseInt($('.RatingGeneralNumber').val()) > 50 ) {
$('.RatingGeneralNumber').css({"color":"green"});
}
});
$('#InterestExpanderX').click(function() {
$('#InterestExpander').fadeOut(250);
});
또한 제가 여기있는 동안 또 다른 질문이 있습니다. 이 사이트에는 여러 영화에 대한 링크가 있습니다. 그들이 영화 링크를 클릭 할 때마다 동일한 div가 팝업되지만 데이터베이스가 말하는 것에 따라 영화에 고유 한 등급이 표시됩니다.
스팬에 영화 등급이 포함 된 것이 "ID"또는 "클래스"유형으로 더 적절할까요, 아니면 둘 다 포함하지 않을까요?
사용 text()
대신 val
스팬 요소 사용text()
$('.InterestLink').click(function() {
$('#InterestExpander').fadeIn(450);
if (parseInt($('.RatingGeneralNumber').text()) > 50 ) {
$('.RatingGeneralNumber').css({"color":"green"});
}
});
$('#InterestExpanderX').click(function() {
$('#InterestExpander').fadeOut(250);
});
.InterestLink {
}
#InterestExpander {
color:white;
background-color:#484848;
position:fixed;
margin-left:auto;
margin-right:auto;
width:700px;
height:480px;
display:none;
box-shadow:0px 0px 5px 0px #000000;
}
#InterestExpanderX {
float:right;
cursor:pointer;
font-family:Arial;
font-size:50px;
}
.RatingGeneralNumber{
display:block;
font-size:22px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<a class="InterestLink">Click me</a>
<div id="InterestExpander">
<div id="InterestExpanderX">
×
</div>
<br><br>
General Rating:
<span class="RatingGeneralNumber">80%</span>
</div>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다