jQuery创建的页面元素未显示在源代码中是否正确? [英] Is it correct that page elements created by jQuery do not show up in the source code

查看:134
本文介绍了jQuery创建的页面元素未显示在源代码中是否正确?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码(摘要):

I have the following code (snippet):

 var numRows = $table.find('tbody tr').length;
var numPages = Math.ceil(numRows / numPerPage);
var $pager = $('<div class="pager"></div>');
for(var page =0; page < numPages; page++) {
 $('<span class="page-number">' + (page + 1) + '</span>')
  .appendTo($pager).addClass('clickable');
  }
 $pager.insertBefore($table);

在查看页面源代码时看不到"<div class="...代码是否正确?

Is it correct that when I view the page source I don't see the "<div class="... code?

推荐答案

是.该源仅用于构建表示文档的初始 DOM .动态创建的元素仅插入到DOM中.

Yes. The source is just used to build the initial DOM that represents the document. Dynamically created elements are only inserted in the DOM.

但是您可以使用DOM浏览器(例如Safari的WebInspector或Firefox扩展Firebug)来分析此类元素. Firefox还可以通过在上下文菜单中选择查看选择源来选择表示该动态创建元素的源代码.

But you can analyse such elements with a DOM viewer like Safari’s WebInspector or the Firefox extionsion Firebug. Firefox can also show source code that represents such dynamically created elements by selecting that element an choosing View Selection Source in the context menu.

这篇关于jQuery创建的页面元素未显示在源代码中是否正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆