Hi all i am working on jquery i need to Use jQuery select() to select content of a div in a popup i had written code in the html page it's working fine but when comes to poup it dosen't work
here i am calling a pop up in that pop up i have a div in that div i have a button in that i am calling a callingmethod(); but i's not working
do i have to change anything in this code please help to make it thanks in advance here my code
<input type="button" id="btncall" onclick="callingmethod('selectable');" value="c0py" />
text to be copy
<div id="selectable">Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Quisque eu ante ac massa dignissim tempor id nec lectus. Vestibulum commodo purus
vel nisl vulputate ac porttitor erat luctus. </div>
here is a calling function
function callingmethod(containerid) {
if (document.selection) {
alert(1);
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select();
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().addRange(range);
}
}
You don't have an element having an id of selectable
anywhere in your code. And thus, are getting an error.
Add the following to your html file:
<input type='text' id='selectable' />
Type something into it. And press copy.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.