Fork me on github

利用Jquery获取、设置iframe中元素

<iframe id="iframe" src="'+url+'"></iframe>';

//iframe加载完成后

$("#iframe").load(function(){

  //设置class="name"的值为jeffson

  $(this).contents().find('.name').val("jeffson");

  //设置class="content"的值为abcdefg

  $(this).contents().find('.content').html("abcdefg");

  //获取class="name"的值

  $(this).contents().find('.name').val();

  //设置单选按钮为选中状态
  $(this).contents().find("input[@type='radio']").attr("checked","true"); 
})

  

posted @ 2016-04-28 14:20  Champion-水龙果  阅读(688)  评论(0编辑  收藏  举报
Champion-水龙果