I had the response on my previous post to select a specific class in a page. (using this)
I'm using Yii framework and the use of this does not work
<div class="ajaxlink">
<?php
echo CHtml::ajaxLink(
'Test request',
array($url_replace),
array(
'update'=>'.loading' ,
'beforeSend' => 'function() {
$(this).removeClass("loading");
$(this).addClass("loading");
}',
)
);
?>
</div>
in short when I click the ajaxlink , I call the action view of my controller which renderPartial a view with ClistView.
I dont know how to solve the problem, with the code above, nothing happens.
If I replace this with Ajaxlink, the class is added to all classes of the page.
To be clear, when the page is rendered, I have a list of post with related links.
<div class="content">
blabla blabla
Link
</div>
<div class="content">
blabla blabla 2
Link
</div>
when I click to the first link , I want to add a class below this link only
Thank you in advance for your help
If I understand you correctly.
Jquery's next()
http://api.jquery.com/next/. Taken from JQuery
<ul>
<li>list item 1</li>
<li>list item 2</li>
<li class="third-item">list item 3</li>
<li>list item 4</li>
<li>list item 5</li>
</ul>
$( "li.third-item" ).next().css( "background-color", "red" );
You could replace .css() with .addClass() and add a click()
So something like this:
$('a').click(function() {
$(this).next('.content').addClass('myClass');
});
Again, if I understand you correctly. This will add a class to the next .content
div after the <a>
is clicked.