このリンクはとても便利だと思いました
ただし、私が今やりたかったのは、このIDを再利用して、実際にループしているテキストボックスごとにトリミング機能を実行することです。私はこのコードを試しました:
<html>
<head>
<?php echo $this->Html->script("jquery-1.4.3.min"); ?>
</head>
<body>
<?php
echo $content_for_layout;
?>
<script type="text/javascript">
$(document).ready(function () {
// alert('JQuery is succesfully included');
/* $(':submit').click(function(){
<?php if(($this->request->controller=='members')&&($this->action=='register')):?>
//alert('well');
var some = $.trim($(":text").val());
alert(some);
<?php endif; ?>
});
*/
$(':submit').click(function(){
$('form input[type="text"]').each(function(){
//get value of id of textbox here
var id = $(this).attr('id');
var some = $.trim($((this).attr('id')).val());
alert(some);
});
});
});
</script>
</body>
</html>
それでもアラートボックスは表示されません。