Căn bản ẩn/hiện

Thí dụ:

Đoạn thẻ HTML

<?php
<div id="demo" style="background:#eee;border:red 1px dashed;text-align:center;padding:11px">
  <
div>[ <a href="javascript://#" id="demo-show">show()</a> ] [ <a href="javascript://#" id="demo-hide">hide()</a> ] [ <a href="javascript://#" id="demo-toggle">toggle()</a> ]</div>
  <
div id="demo-display" style="text-align:center;border:1px #333 solid;background:#ffffdd;margin:11px;padding:11px">.SHOW() / .HIDE() / TOGGLE()</div>
</
div>
?>

Đoạn javascript

<?php
<script>
$(
document).ready(function(){
  $(
'#demo-show').click(function(){
    $(
'#demo-display').show('slow');
  });
  $(
'#demo-hide').click(function(){
    $(
'#demo-display').hide('slow');
  });
  $(
'#demo-toggle').click(function(){
    $(
'#demo-display').toggle('slow');
  });
});
</script>
?>





[ show() ] [ hide() ] [ toggle() ]
.SHOW() / .HIDE() / TOGGLE()





Comments

hi! cái này chỉ áp dụng được

hi!
cái này chỉ áp dụng được cho 1 . nếu mà muốn sử dụng chung cho nhiều có cách nào ko? thanks TH.

Thanks!

Áp dụng nhiều có thể sử dụng

Áp dụng nhiều có thể sử dụng tương đương, gom 1 số các thẻ có cùng ID hoặc class. Ví dụ
$('div[id^=div]') sẽ gọi các thẻ div có Id bắt đầu bằng div

Áp dụng nhiều có thể sử dụng

Áp dụng nhiều có thể sử dụng tương đương, gom 1 số các thẻ có cùng ID hoặc class. Ví dụ
$('div[id^=div]') sẽ gọi các thẻ div có Id bắt đầu bằng div

Gom nhiều thằng cùng lúc thì

Gom nhiều thằng cùng lúc thì làm câu dạng nt này:

  1. jQuery('.class1, #ID2, tag3').addClass('foo').removeClass('bar');

Thế Hồng

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <sup> <br> <p> <h3>
  • Lines and paragraphs break automatically.
  • Link to content with [[some text]], where "some text" is the title of existing content or the title of a new piece of content to create. You can also link text to a different title by using [[link to this title|show this text]]. Link to outside URLs with [[http://www.example.com|some text]], or even [[http://www.example.com]].
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.