Jump to content
php.lv forumi

pogai vajag class="current" no onclick


anonīms

Recommended Posts

ar php viss būtu skaidrs, bet izmantoju šādu, jquery.

<div class="tab"><a href="#" onclick="radit('viesi'); return false;" <?php if($_GET['o'] == 'viesi' OR !$_GET['o']) { echo 'class="current"'; }?>>Viesi</a></div>
<div class="tab"><a href="#" onclick="radit('draugi'); return false;" <?php if($_GET['o'] == 'draugi') { echo 'class="current"'; } ?>>Draugi</a></div>

kā man linkiem pielikt klasi, kad uzspiež, jo reāli jau gets pie linka neparādas?

Vajag, kad uzspiež uz linka tas kļūtu current (darbojas ar jquery)

Edited by anonīms
Link to comment
Share on other sites

Piemet vajadzīgajiem linkiem klasi "selectable"

(es ceru, ka tu zini, ka vienam elementam var būt vairākas klases, piem. <div class="box selected">)

 

 

<a href="#" onclick="" class="selectable"></a>

 

Tad dinamiski ar jquery pievieno click eventu.

 

$(document).ready(function(){
$("a.slectable").click(function(){
//novācam visiem iepriekšējiem to clicked klasi
$("a.slectable").removeClass("clicked");
//pievienojam īstajam
$(this).addClass("clicked");

});
});

 

...un viss :)

 

..uhh, kā mīlu jquery :D

 

 

 

 

hmm, a kādā sakāra tev tur php kodā if'a ir "OR", nevis "||" ??

Edited by briedis
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...