CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   jQuery 'hiding' content on search output page (http://www.codingforums.com/showthread.php?t=283730)

Subyne Simean 12-07-2012 08:35 AM

jQuery 'hiding' content on search output page
 
Hello I was wondering if you may be able to help with this problem.

I have a PHP search results output page. In the search results I want to have a copy button next to some of the results so users can easily copy them to their clipboard.

The jQuery I'm using only works when I output the following script along with the results (i.e. it won't work if I just have it on the page statically).

Code:

$('.copy').click(function() {
   
    var row = $(this).closest('td');

   
    var txt = row.find('span:first');

   
    window.clipboardData.setData('Text', txt.text());

   
    var range = document.body.createTextRange();
    range.moveToElementText(txt[0]);
    range.select();
});

the HTML...

<td><span>Name from DB here</span> <button class="copy">COPY</button></td>

<td><span>Phonefrom DB here</span> <button class="copy">COPY</button></td>

<td><span>Email from DB here</span> <button class="copy">COPY</button></td>

So yes it works if I do it that way, but everything above the script gets hidden (behaves like the elements have display: none set). I have a form above the script that needs to be on the page.

Please help!!!

VIPStephan 12-07-2012 11:00 AM

I don’t see anything that would hide the content. Use a debugging tool (usually built into the browser already) and see what really happens. Also, you are adding a “DOM ready” function to your script or loading it at the end of the document, aren’t you?


All times are GMT +1. The time now is 06:45 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.