Displaying posts categorized under

jQuery

[jQuery] スムーズスクロール

$(document).ready(function(){ $(‘a[href*=#]‘).click(function() { if (location.pathname.replace(/^\//,”) == this.pathname.replace(/^\//,”) && location.hostname == this.hostname) { var $target = $(this.hash); $target = $target.length && $target || $(‘[name=' + this.hash.slice(1) +']‘); if ($target.length) { var targetOffset = $target.offset().top; $(‘html,body’).animate({scrollTop: targetOffset}, 1000); return false; } } }); });

[CakePHP][jQuery] jQueryでフォームをリセットする

jQueryを使ってフォーム要素をリセットしてみた。 <?php $this->Html->scriptStart();?> $(function(){ // 検索フォームの入力値をリセット $("button.reset").click(function(){ $(‘input[type="text"], input[type="radio"], input[type="checkbox"], select’). val(""). removeAttr(‘checked’). removeAttr(‘selected’) }) }) <?php echo $html->scriptEnd();?> //form echo $form->create(); echo $form->text(‘name’); echo $form->text(‘tel’); echo $form->button(‘reset’, array(‘class’ => ‘reset’)); echo $form->end(); ?> ※jQueryへのパスは適宜変更すること。