JQuery issue. Click - open code

I have this JQuery code

jQuery(\'.tpcoupon-reveal\').click( function() {
jQuery(\'.inner-code\').css(\'background-color\',\'#FFF\');
jQuery(\'.inner-code\').text(jQuery(this).attr(\'caption\'));
visitstore = jQuery(this).attr(\'url\');
window.open(visitstore);
    });

$newText = '

            <div class="tpcoupon-code-wrapper">
                <span class="tpcoupon-msg"> '.tpbox2_unhtmlentities($content).'</span>
                <span class="tpcoupon-reveal" caption="'.$couponcode.'" url="'.$url.'">Vis koden & bes√łg siden</span>
                <span class="tpcoupon-code-show">
                    <span class="inner-code"></span>
                </span>
            </div>
            <div class="clr"></div>
';

Due to this code when I click on span object with id tpcoupon-reveal it shows me code in span object with id inner-code The problem is that I have many blocks in one page. But when I click one span it opens all codes in all span with id=inner-code How to make JQuery to open only this block?

Answers


Try scoping the jQuery seletor for '.inner-code' by doing this inside the click handler:

$(this).parent().find('.inner-code')

Need Your Help

Where is PyQt event loop running?

python pyqt

If I open a Python interpreter and enter the following lines

how to display the items in the combobox in any given manner?

c# javascript asp.net

I have a dropdown getting populated by fetching a query on the database.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.