jquery自定义属性(类型/属性值)
<script src="jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var ping = '';
switch ($('#Select3 option:selected').text()) {
case '图片': ping += '<img'; break;
case '文本框': ping += '<input type=text'; break;
case '按钮': ping += '<input type=button'; break;
}
$('#attrzhi').blur(function () {
ping += ' ';
ping += $('#Select2 option:selected').text();
ping += '=';
ping += $('#attrzhi').val();
})
$('#Button1').click(function () {
ping += '/>';
alert(ping);
$('#show').append(ping);
})
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr><td><!--什么东西--> 添加类型:</td><td><select id="Select3">
<option>图片</option>
<option>文本框</option>
<option>按钮</option>
</select></td><td rowspan="5" id='show'></td></tr>
<tr><td>
<!--需要设置的属性值-->
属性:</td><td> <select id="Select2">
<option>src</option>
<option>width</option>
<option>height</option>
<option>title</option>
<option>value</option>
<option>font-size</option>
<option>color</option>
</select>
</td></tr>
<tr><td>属性值:</td><td><input id="attrzhi" type="text" /></td></tr>
<tr><td colspan="2"><div id="showattr"></div></td></tr>
<tr><td> 内容:</td><td><input id="Text1" type="text" /></td></tr>
<tr><td>
<input id="Button1" type="button" value="创建" /></td></tr>
</table>
</div>
</form>
</body>