Lidemy / mentor-program-2nd-at7211

mentor-program-2nd-at7211 created by GitHub Classroom
1 stars 1 forks source link

jQuery #13

Open at7211 opened 6 years ago

at7211 commented 6 years ago
parseInt() //將數字從字串轉換成數字(預設抓取都是字串)
at7211 commented 6 years ago

ajax

$.ajax(
  {
      url:data_url,
      success: function(res){
        console.log(JSON.parse(res));
      }
  }
)
at7211 commented 6 years ago
 var now_class="";
          if(item.done == true){
            now_class="done"
          }

//上下意思相同,寫法不同
     var now_class=(item.done==true)?"done":"";
at7211 commented 6 years ago
   var now_item=item_template.replace("{{name}}",item.name) 
                                    .replace("{{num}}",i+1)
                                    .replace("{{date}}",item.date)
                                    .replace("{{class}}",now_class);
          //replace("",123)前者為替換對象,後者為給定值
at7211 commented 6 years ago
  $(".question").addClass("select") //注意addClass()裡面不用加.
at7211 commented 6 years ago

動態綁定失效解決辦法

$(".topic").on("click","title",function(){
  $(this).css("border-bottom","solid 1px #358bff");
  console.log("click!");
})