jQuery通过方法append(function(index,html))插入节点


在Jquery中,append函数的额功能是将function函数作为append的参数,该函数的功能是返回一个字符串,作为append方法插入点的内容。

示例:

  1. <script type="text/javascript">  
  2.         $(function() {  
  3.             $("div").append(retHtml); //插入内容  
  4.             function retHtml() {  
  5.                 var str = " <b>Write Less Do More</b> ";  
  6.                 return str;  
  7.             }  
  8.         })  
  9.     </script>  

相关内容