标签:
1:IMG图片的动态取值赋值
$("#imgId")[0].src;
$("#imgId").attr(‘src‘,path);
2:JAVASCRIPT DEBUG调试
debugger;
3:JSTL判断
语法:
<c:choose>
<c:when test = "${}">
结果一
</c:when>
<c:otherwise>
结果2
</c:otherwise>
</choose>
<c:choose>
<c:when test="${userCourse.courseID.bookDinner}">
<c:choose>
<c:when test="${userCourse.bookDinner}">
结果一
</c:when>
<c:otherwise>
结果二
</c:otherwise>
</c:choose>
</c:when>
<c:otherwise>
结果三
</c:otherwise>
</c:choose>
4:Radio选择切换
>> 获取某个选中按钮值:
$(‘input[name="testradio"]:checked‘).val();
>> 循环所有的单选按钮:
$("input[name=‘radioName‘]").each(function(index,value){
//当前对象$(this)
//第2个对象(或者根据index进行判定)
$(‘input[name="radioName"]:eq(1)‘).val()
});
5:checkbox选择
>> 判定是否选中
function validateCheckBox(){
var object = $("#agreeCheck").is(‘:checked‘);
if(object){
$("#agreeCheckTip").hide();
return true;
}else{
$("#agreeCheckTip").show();
return false;
}
}
>> checkbox 修改页面选中
<c:forEach items="${qy:findDictionaryByCoding(‘investorLike‘)}" var="item">
<div class="xuan01">
<div class="fang">
<input type = "checkbox" name = "likeIds" value = "${item.id }"
<c:forTokens var="it" items="${investor.likeIds}" delims=",">
<c:if test="${item.id == it}">checked="checked"</c:if>
</c:forTokens>
/>
</div>
<span>${item.name }</span>
</div>
</c:forEach>
6:select 取值赋值(文本值)
>> var checkText=$("#select_id").find("option:selected").text(); //获取Select选择的Text
>> var checkValue=$("#select_id").val(); //获取Select选择的Value
>> var checkIndex=$("#select_id ").get(0).selectedIndex; //获取Select选择的索引值
>> var maxIndex=$("#select_id option:last").attr("index"); //获取Select最大的索引值
>> $("#select_id ").get(0).selectedIndex=1; //设置Select索引值为1的项选中
>> $("#select_id ").val(4); // 设置Select的Value值为4的项选中
>> $("#select_id option[text=‘jQuery‘]").attr("selected", true); //设置Select的Text值为jQuery的项选中
标签:
原文地址:http://www.cnblogs.com/goldberg/p/5438171.html