【发布时间】:2016-08-22 17:03:26
【问题描述】:
我在脚本中有一些数据需要排列在数据表中。我不知道如何实现这一点,因为我是一个新手,还在学习。
数据在:
<script>
var $textarea = $('#TextArea1'), $submit = $('#Submit1');
$submit.click(function (e) {
e.preventDefault();
sourceCode = $textarea.val();
var $searchObject = $('<div id="Searching"></div>');
$searchObject.append($(sourceCode));
alert("Number of text boxes = " + $searchObject.find('[type=text]').length);
$searchObject.find('[type=text]').each(function () {
alert("Name of textbox = " + $(this).attr("name") + " and its ID is " + $(this).attr("id"));
});
alert("Number of Submit Buttons = " + $searchObject.find('[type=submit]').length);
$searchObject.find('[type=submit]').each(function () {
alert("Name of Submit button = " + $(this).attr("name") + " and its ID is =" + $(this).attr("id"));
});
alert("Number of Telephone entry fields = " + $searchObject.find('[type=tel]').length);
$searchObject.find('[type=tel]').each(function () {
alert("Name of Telephone entry field button = " + $(this).attr("name") + " and its ID is =" + $(this).attr("id"));
});
alert("Number of Password boxes = " + $searchObject.find('[type=password]').length);
$searchObject.find('[type=password]').each(function () {
alert("Name of Password box = " + $(this).attr("name") + " and its ID is =" + $(this).attr("id"));
});
alert("Number of check boxes = " + $searchObject.find('[type=checkbox]').length);
$searchObject.find('[type=submit]').each(function () {
alert("Name of Submit button = " + $(this).attr("name") + " and its ID is =" + $(this).attr("id"));
});
alert("Number of Radio buttons on page = " + $searchObject.find('[type=radio]').length);
$searchObject.find('[type=radio]').each(function () {
alert("Name of radio button = " + $(this).attr("name") + " and its ID is =" + $(this).attr("id"));
});
alert("Number of drop down lists = " + $searchObject.find('select').length);
$searchObject.find('[type=select]').each(function () {
alert("Name of select button = " + $(this).attr("name") + " and its ID is =" + $(this).attr("id"));
});
alert("Number of Images on page = " + $searchObject.find('img').length);
$searchObject.find('[type=img]').each(function () {
alert("Name of Image = " + $(this).attr("name") + " and its ID is =" + $(this).attr("id"));
});
alert("Number of Hyperlinks on page = " + $searchObject.find('a[href]').length);
alert("Number of Buttons = " + $searchObject.find('[type=button]').length);
$searchObject.find('[type=button]').each(function () {
alert("Name of button = " + $(this).attr("name") + " and its ID is =" + $(this).attr("id"));
});
alert("Number of Date entry fields= " + $searchObject.find('[type=date]').length);
$searchObject.find('[type=date]').each(function () {
alert("Name of date button = " + $(this).attr("name") + " and its ID is =" + $(this).attr("id"));
});
});
</script>
我想将此数据绑定到数据表中,并将其显示在网页中,而不是将它们显示为警报弹出窗口。数据需要整理在表格下的
<table>
<tr>
<th>Element </th>
<th>Element name</th>
<th>Element ID</th>
</tr>
</table>
实现这一目标的最佳方法是什么?任何人都可以帮我解决这个问题的代码吗?
提前致谢。
【问题讨论】:
-
不清楚你在问什么?您想从脚本的数据创建数据表吗?如果是这样,为什么不在代码中编写代码并创建数据表?
标签: jquery html asp.net html-table