通过Id遍历标签

来源:互联网 发布:淘宝抓绒衣 编辑:程序博客网 时间:2024/05/29 15:35
$("input").each(function(){
var idobj=$(this).attr("id")
var dd=$(this).val();
document.getElementById(idobj).setAttribute("value", dd);
});
$("textarea").each(function(){
var idobj=$(this).attr("id")
var dd=$(this).val();
$(this).html(dd);
//document.getElementById(idobj).innerHTML =dd;
});
//遍历单选
$('input:radio:checked').each(function () {
var idobj = $(this).attr("id");
document.getElementById(idobj).setAttribute("checked", "checked");
});
//遍历多选
$('input:checkbox:checked').each(function () {
var idobj = $(this).attr("id");
document.getElementById(idobj).setAttribute("checked", "checked");
});

$('select option:selected').each(function () {
var idobj = $(this).attr("id");
document.getElementById(idobj).setAttribute("selected", "selected");


});



<fmt:formatDate value="${t.startTime}" type="date" dateStyle="long"/>
<fmt:formatDate value="${t.startTime}" type="time"/>

0 0
原创粉丝点击