Jump to content
php.lv forumi

jquery slideDown uzspiežot uz title


ziedinjsh

Recommended Posts

izvandījos pa googli un laikam es nevaru tik galā ar to ko man vajag.

 

php


echo "<div id='record_list'>";
$records = mysql_query("select * from records where uid='".$data['id']."' order by id desc") or die(mysql_error());
echo "<ul style='list-style:none;margin:0;padding:0;'>";
while($data = mysql_fetch_array($records)){
echo "
<li id='record'><p id='title_link'><b>+</b> ".$data['title']."</p>
<div style='display:none;' id='under".$data['id']."'>".$data['content']."</div>
</li>
";
}
echo "</ul>";
echo "</div>";

 

sarakstā rādās nosaukums. uzspiežot uz viņu vajadzētu parādīties saturam kas ir zem nosaukuma

 

jquery


$(function(){
$('#title_link').click(function(){
$('#under'+id).slideDown('slow');
});
});

 

 

spiežot uz title_link nekas nenotiek!!! kapēc!?

Link to comment
Share on other sites

Kā man reāli besī skatīties uz šito "Es zinu, ko tu man saki ka man ir nepareizi" - ja nezini, nerunā! ID ir unikāls, tev viņš nav unikāls un kas tas par js mainīgo? pats vispār saproti ko dari?

 

<?
if(is_numeric($data['id']) && $data['id'] > 0){
$records = mysql_query("select * from records where uid={$data['id']} order by id desc");
if(mysql_num_rows($records)){
?>
<div id="record_list">
<ul style="list-style-type:none;margin:0px;padding:0px;">
<? while($row = mysql_fetch_object($records)){ ?>
<li>
<p><strong>+</strong> <?=$row->title?></p>
<div style="display:none"><?=$data->content?></div>
</li>
<? } ?>
</ul>
</div>
<script type="text/javascript">
$(function(){
  $('#record_list li p:first').click(function(){
     if($(this).next().is(':visible')){
		$(this).next().hide();
     }else{
		$(this).next().show();
     }
  });
});
</script>
<? }else{ ?>
<p>Man nav ko tev parādīt</p>
<? } ?>

<? }else{ ?>
<p>Tu nemāki norādīt pareizu ID</p>
<? } ?>

Edited by EdgarsK
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...