I ve got HTML Code similar to this one:
<pre>
words words words
words <span> words mystery words</span>
words words words
</pre>
关于pre的标签,我想得到“神秘”的特性的抵消。 我可以拿到“span> tag”使用“Node”财产,但我无法找到一个途径来获得“<>pre标签”。
I ve got HTML Code similar to this one:
<pre>
words words words
words <span> words mystery words</span>
words words words
</pre>
关于pre的标签,我想得到“神秘”的特性的抵消。 我可以拿到“span> tag”使用“Node”财产,但我无法找到一个途径来获得“<>pre标签”。
http://www.w3.org/TR/DOM-level-2-Traversal-Range/ranges.html 为此:
function getCharOffsetRelativeTo(container, node, offset) {
var range = document.createRange();
range.selectNodeContents(container);
range.setEnd(node, offset);
return range.toString().length;
}
例:
var sel = window.getSelection();
var pre = document.getElementById("your_pre_id");
var offset = getCharOffsetRelativeTo(pre, sel.anchorNode, sel.anchorOffset);
洞穴:
<script>
or <style>
tags and invisible elements (hidden by CSS display: none
, for example).您可以写出一种方法,以补偿性办法计算它。 这种方法可确定被遗忘的特性,然后将母子的分数跨出,然后从小到一开始......再到所期望的标签(之前)找到,或者直到你从tag子中排出为止。
I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....
I have a div <div id="masterdiv"> which has several child <div>s. Example: <div id="masterdiv"> <div id="childdiv1" /> <div id="childdiv2" /> <div id="...
I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...
<form><input type="file" name="first" onchange="jsFunction(2);"> <input type="file" name="second" onchange="jsFunction(3);"</form> Possible to pass just numbers to the js ...
So I ve got a menu with a hover/selected state and it loads fine in IE6/IE7. However when I scroll down the page and put the element outside of the viewport and then back in I get a broken image! I ...
I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!