JQuery常用操作HTML

$("li").each(function(){
    alert($(this).text())
  });
$('input[type="checkbox"][name="chk"]:checked').each(
                function() {
                       a=a+"|"+$(this).val();   
                }
            );
//var followers = document.getElementsByName("followers");
var f_str = '0';
$("input[@name='followers']").each(function(){
   if($(this).attr("checked")==true){
    f_str += ","+$(this).attr("value");
   }
})
$("input:checkbox").each(function(){
   alert($(this).attr("checked"));
if($(this).attr("checked")=="checked"){
alert("哈哈,我被选中了");
}

https://www.sitepoint.com/jquery-check-checkbox-checked/

$("input[type=checkbox]").bind("click", function () {
            var pid = $(this).attr("id");

            var chk = $("#tppdesc").find("#" + pid + "d");
            if (chk.length == 0)
                $("#test_purpose_desc").before("<p><span><lable>" + $(this).attr("hiv") + ": </lable></span><input class='required' type='text' id='" + pid + "d' name='" + pid + "d' /></p>");
            else
                chk.parent().remove();
        });

 

posted @ 2017-05-12 11:57  chy710  阅读(41)  评论(0)    收藏  举报