prepend
English [pri:'pend] US [pri:'pend]
vt. ?? ????, ?? ????, premeditate
jquery prepend() ??? ???
??: prepend() ???? ??? ??? ?? ??(?? ??)? ??? ??? ?????. prepend() ? prependTo() ???? ??? ??? ????. ???? ??? ????. ??? ???? ??? prependTo() ??? ???? ??? ??? ? ??? ?????.
??: ??$(selector).prepend(content)
????:
Parameters | Description |
content | ?????. ??? ???? ?????(HTML ?? ?? ??). |
??? ???? ??? ??: ??? ???? ??? ??? ?? ??? ??? ???? ?????.
??: ??$(selector).prepend(function(index,html))
????:
???? | Description |
function(index,html) | ?????. ??? ??? ???? ??? ?????. |
index | ????. ???? ??? ??? ?????. |
html | ????. ???? ?? HTML? ?????. |
jquery prepend() ??? ?
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("p").prepend("<b>Hello world!</b> "); }); }); </script> </head> <body> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button>在每個 p 元素的開頭插入內(nèi)容</button> </body> </html>
??? ????? ??? "???? ??" ??? ?????