how do i build a dynamic selector
I'm having some problems creating a dynamic selector.
I'm using the BeautyTips plugin and i can attach a tooltip to a div by using the id of the div, for example:
- $('example2').bt({ // attaching to one element by id
- contentSelector: "$('#example2-content')" // this will return, as the tooltip's content, what's in example2-content
- });
This works well BUT: how do I make the content selector dynamic if i need to attach a pop-up to multiple images like this:
- $('#test img').bt({ // i'm selecting multiple images in the test div
- contentSelector: "$('#example2-content')" // this will return the SAME content for all images
- });
So this is what i struggle with: changing that "example2" to be dynamic something like this:
- $('#users img').bt({
- contentSelector: "$('#example"+ $(this).attr('id') +"')"
- });
for some reasong this type of concatenation doesn't work and i feel i'm missing something very basic in building that dynamic id.