能贴完整代码吗? 我想你没有理解prependTo()示例 描述: 把所有段落追加到ID值为foo的元素中。HTML 代码: <p>I would like to say: </p><div id="foo"></div>jQuery 代码: $("p").prependTo("#foo");结果: <div id="foo"><p>I would like to say: </p></div>
<!DOCTYPE html> <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").click(function(){ $("<b>Hello World!</b>").prependTo("p[name=aa]"); }); }); </script> </head> <body> <p name='aa'>This is a paragraph.</p> <p>This is another paragraph.</p> <button>Insert content at the beginning of each p element</button> </body> </html>$(content).prependTo(selector)。。你选择器写的不对。。参考上面
描述:
把所有段落追加到ID值为foo的元素中。HTML 代码:
<p>I would like to say: </p><div id="foo"></div>jQuery 代码:
$("p").prependTo("#foo");结果:
<div id="foo"><p>I would like to say: </p></div>
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("<b>Hello World!</b>").prependTo("p[name=aa]");
});
});
</script>
</head>
<body>
<p name='aa'>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>Insert content at the beginning of each p element</button>
</body>
</html>$(content).prependTo(selector)。。你选择器写的不对。。参考上面
$.post('fagetsid.php', //ajax 请求获得SID的页面
{'dt':$('#dat1').val()}, //传递数据
function(data){
var html="<tr><td class='linenumber'><input name='SID[]' type='text' size=17 /></td><td><input name='DeviceNumber[]' type='text' size=20 /></td>";
html+="<td><input name='Mointor[]' type='text' /></td><td><input name='DVD[]' type='text'/></td>";
$("select option:selected").prependTo("attr(name='DVD')");
<td><select name="Depart" >
<option>所有部门</option>
<?php
$conn=mysql_connect("localhost","root","") or die('连接失败'); mysql_select_db("departpc",$conn) or die('连接数据库失败'); mysql_query("SET NAMES 'gb2312'");
$sql="select * from depart";
$result=mysql_query($sql,$conn);
while($row=mysql_fetch_array($result))
{
echo '<option>'.iconv('gb2312','utf-8',$row[1]).'</option>';//输出部门名
}
?>
</select></td>