ユーザーがカテゴリを選択したときにコンテンツがdiv
に読み込まれるというスクリプトがあります。私はまたpre
タグをクリックすると、テキストを選択してコピーするスクリプトがあります。事はそれはコンテンツが私の英語here a exampleためところで申し訳ありませんが、ロードされ、ここでは、ここに私のコード.load()にロードされたコンテンツが表示されない
$(document).ready(function() {
$("#esto").on("change", function() {
var vale = this.value
$("#divcontent").load("http://letraspiolas.com/" + vale + ".html");
});
});
(function() {
function selectText(a) {
var b = document,
text = a,
range, selection;
if (b.body.createTextRange) {
range = b.body.createTextRange();
range.moveToElementText(text);
range.select()
} else if (window.getSelection) {
selection = window.getSelection();
range = b.createRange();
range.selectNodeContents(text);
selection.removeAllRanges();
selection.addRange(range)
}
}
preTags = document.getElementsByTagName("pre");
for (var i = 0; i < preTags.length; i++) {
preTags[i].onclick = function() {
selectText(this);
document.execCommand("copy")
}
}
})();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<select id="esto" data-placeholder="select a category...">
<option value="">select</option>
<option value="test"> test </option>
<option value="test1">test1</option></select>
<div id="divcontent">
<pre>this text can be select and copy</pre>
</div>
</body>
これはtest.htmlというの内容であるされている場合に機能していないです:
<h3>title</h3>
<div class="kghjghjg">
<pre>____i want to select this</pre>
<pre>_____and this</pre>
<div class="clear"></div>
</div>
感謝を –
plzはそれを受け入れる;) – pirs