I have a #pdfcontainer which is inside divs #main and #pdfmain. I’m using a variable, because I use the same div many times:
var $pdfcontainer = $('#main #pdfmain #pdfcontainer');
Inside the #pdfcontainer I have #delete which I want to access for various reasons. So how do I get it using the variable and without typing the whole $(‘#main …’) all over again? I don’t just want to use selector $(‘#delete’) because on my site it’s much slower that way.
Thnx already!
- Antti
Specify
$pdfcontaineras context to your selector like this:Make sure that you have only one item with unique ids, for example, you should have id
#deleteassigned to only one element.