How to Use jQuery select() to select content of a div in a popup?

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) {
                var range = document.body.createTextRange();
            } else if (window.getSelection) {
                var range = document.createRange();


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.


Need Your Help

Assign Datepicker on dynamic textboxes in jquery

javascript jquery datepicker

Please find the below code for more information.

Auto recover Connections in Wildfly 8.2 for Oracle without using validate-on-match

java oracle jboss oracle11g connection-pooling

I am using wildfly 8.2 and oracle 11g and I have my connection pool flushing an invalid connection and creating a new one if possible. I'm using Spring and Hibernate at the back-end too (we are loo...