dom

每日思考(2020/01/15)

拟墨画扇 提交于 2020-01-16 00:06:04
题目概览 DOM和BOM有什么区别? 让网页的字体变得清晰,变细用CSS怎么做? 写一个方法把0和1互转(0置1,1置0) 题目解答 DOM和BOM有什么区别? DOM 是 Document Object Model 的缩写。即文档对象模型,遵循 W3C 制定的标准。提供了独立于内容而与浏览器窗口进行交互的对象。描述了与浏览器进行交互的方法和接口,可以对浏览器窗口进行访问和操作,譬如可以弹出新的窗口,改变状态栏中的文本。其本质就是 DOM 元素。最早使用的 document.getElementById 获取到的对象就是 DOM 对象。利用 JS 操作某个 DOM 的颜色、形状、大小都是对 DOM 元素的操作。在代码上可以理解为 document 开头的方法和属性 BOM 是 Browser Object Model 的缩写。即浏览器对象模型,这并没有一套规定标准,每个浏览器都有自己的实现DOM 是针对 HTML 的基于树的 API。描述了处理网页内容的方法和接口,是 HTML 的API,DOM 把整个页面规划成由节点层级构成的文档。但事实上在大部分主要的功能上都已经形成默契。BOM 主要操作浏览器的行为,比 navigator , location , history , storage 都为 BOM 的操作。其根对象是 window,可以理解为 winodw 开头的方法 关系

jQuery——选择器

扶醉桌前 提交于 2020-01-15 20:10:22
1、层级选择器 选择器是jQuery的核心。一个选择器写出来类似 $('#dom-id') 。 公式 : $(选择器).事件(事件函数) 回顾DOM操作中我们经常使用的代码: // 按ID查找: var a = document.getElementById('dom-id'); // 按tag查找: var divs = document.getElementsByTagName('div'); // 查找<p class="red">: var ps = document.getElementsByTagName('p'); // 过滤出class="red": // TODO: // 查找<table class="green">里面的所有<tr>: var table = ... for (var i=0; i<table.children; i++) { // TODO: 过滤出<tr> } 这些代码实在太繁琐了,并且,在层级关系中,例如,查找 <table class="green"> 里面的所有 <tr> ,一层循环实际上是错的,因为 <table> 的标准写法是: <table> <tbody> <tr>...</tr> <tr>...</tr> </tbody> </table> 很多时候,需要递归查找所有子节点。

Binding jquery-multifile to a dynamically loaded form

﹥>﹥吖頭↗ 提交于 2020-01-15 19:13:20
问题 I am using the jquery multifile plugin found here: http://www.fyneworks.com/jquery/multiple-file-upload/ I've used it in the past and had no problems, but now I am trying to use it in a dynamically loaded form and it's causing a strange issue. I am binding the function correctly when loading the form as per this article, so please understand this is a DIFFERENT, albeit related, problem to the one posted here: Cannot bind input event to jQuery multifile from dynamically loaded form $('

Binding jquery-multifile to a dynamically loaded form

时光怂恿深爱的人放手 提交于 2020-01-15 19:13:17
问题 I am using the jquery multifile plugin found here: http://www.fyneworks.com/jquery/multiple-file-upload/ I've used it in the past and had no problems, but now I am trying to use it in a dynamically loaded form and it's causing a strange issue. I am binding the function correctly when loading the form as per this article, so please understand this is a DIFFERENT, albeit related, problem to the one posted here: Cannot bind input event to jQuery multifile from dynamically loaded form $('

Binding jquery-multifile to a dynamically loaded form

两盒软妹~` 提交于 2020-01-15 19:12:31
问题 I am using the jquery multifile plugin found here: http://www.fyneworks.com/jquery/multiple-file-upload/ I've used it in the past and had no problems, but now I am trying to use it in a dynamically loaded form and it's causing a strange issue. I am binding the function correctly when loading the form as per this article, so please understand this is a DIFFERENT, albeit related, problem to the one posted here: Cannot bind input event to jQuery multifile from dynamically loaded form $('

PHP DOMDocument calling getElementsByTagName on a NodeList

余生长醉 提交于 2020-01-15 18:50:50
问题 I'm trying to traverse a DOM tree in PHP using DOMDocument. Initial calls to getElementById / getElementsByTagName are successful, but I'm not sure how to proceed with the resulting NodeList. Here's an example HTML file that I'm trying to traverse. <!DOCTYPE html> <html> <div id="container"> <p> Hello </p> </div> </html> In Javascript I'd be able to chain DOM traversal methods like so: document.getElementById('container').getElementsByTagName('p')[0].innerText // returns "Hello" However in

PHP DOMDocument calling getElementsByTagName on a NodeList

给你一囗甜甜゛ 提交于 2020-01-15 18:47:09
问题 I'm trying to traverse a DOM tree in PHP using DOMDocument. Initial calls to getElementById / getElementsByTagName are successful, but I'm not sure how to proceed with the resulting NodeList. Here's an example HTML file that I'm trying to traverse. <!DOCTYPE html> <html> <div id="container"> <p> Hello </p> </div> </html> In Javascript I'd be able to chain DOM traversal methods like so: document.getElementById('container').getElementsByTagName('p')[0].innerText // returns "Hello" However in

Using this within functions called with onclick event in Javascript

一个人想着一个人 提交于 2020-01-15 18:46:51
问题 I'm currently building a small Todo list application using vanilla Javascript but I'm having some issues creating a delete button that onClick removes it's parent element. From what I have read, when an onClick is called in Javascript the this keyword can be used to refer to the element that called the function. With this in mind I have the following code: window.onload = initialiseTodo; function addRecord(){ var title = document.getElementById('issueTitle'); var issueContent = document

inline copy paste JEditorPane HTML

冷暖自知 提交于 2020-01-15 12:33:52
问题 I'm desperatly trying to implement a customized copy/paste in a JTextPane in HTML mode. The most part is working well, I get the html content using EditorKit.write(), I paste it using editorKit.read(). Perfect world. BUT, when I have : <p> test </p> in my editor and I try to copy "es" to obtain <p> tesest </p> , I obtain instead <p>tes</p> <p>es</p> <p>t</p> Knowing that, I m trying to figure out a way to paste "inline" the part supposed to be inline, and in block the part which was in block

jQuery Append order?

孤人 提交于 2020-01-15 12:33:36
问题 I'm creating a series of comments, with replies to the comments below them. I use this code to append the new reply underneath the comment. $(document).on('click', '.sub-reply1-send', function() { var reply = $('textarea[name=comment-reply]').val(); $('.sub-reply1, .sub-reply1-textarea, .sub-reply1-send').slideUp(250).remove(); $('.answer').append("<div class='comment-sub-reply' style='display:none'>" + reply + "</div>"); $('.comment-sub-reply').slideDown(250); subreply_visible = false; });