Javascript 为什么我不能在jquery中选择元素并更改内容
我无法选择元素并更改其中的内容 这是我的htmlJavascript 为什么我不能在jquery中选择元素并更改内容,javascript,php,jquery,html,Javascript,Php,Jquery,Html,我无法选择元素并更改其中的内容 这是我的html <div class="like_user_wrapper" id="<?php echo $post_id.'like_user_wrapper' ;?> "> hello, world </div> <span class="post_bottom_bar"> <img class="thumb_icon" onmouseover=" var post_id=<?php ec
<div class="like_user_wrapper" id="<?php echo $post_id.'like_user_wrapper' ;?> ">
hello, world
</div>
<span class="post_bottom_bar">
<img class="thumb_icon" onmouseover="
var post_id=<?php echo $post_id ?>;
$.ajax({
url:'ajax_like_user.php',
method:'post',
data:{post_id:post_id},
success:function(data){
$('<?php echo '#'.$post_id.'like_user_wrapper' ?>' ).html('hello');
}
})
" >
您在id=”“部分中有一个额外的空间。将其更改为:
id="<?php echo $post_id.'like_user_wrapper' ;?>">
id=”“>
注意;?>代码>已删除。您在id=”“部分中有一个额外的空间。将其更改为:
id="<?php echo $post_id.'like_user_wrapper' ;?>">
id=”“>
注意;?>代码>已删除。您在id=”“部分中有一个额外的空间。将其更改为:
id="<?php echo $post_id.'like_user_wrapper' ;?>">
id=”“>
注意;?>代码>已删除。您在id=”“部分中有一个额外的空间。将其更改为:
id="<?php echo $post_id.'like_user_wrapper' ;?>">
id=”“>
注意;?>代码>被删除。您可以这样做:
<img class="thumb_icon" />
<script>
$(".thumb_icon").mouseover(function(){
var post_id=<?php echo $post_id ?>;
$.ajax({
url:'ajax_like_user.php',
method:'post',
data:{post_id:post_id},
success:function(data){
$('<?php echo '#'.$post_id.'like_user_wrapper' ?>' ).html('hello');
}
})
})
</script>
$(“.thumb_图标”).mouseover(函数(){
var post_id=;
$.ajax({
url:'ajax_like_user.php',
方法:'post',
数据:{post_id:post_id},
成功:功能(数据){
$('').html('hello');
}
})
})
或
函数mouseoverImg(){
var post_id=;
$.ajax({
url:'ajax_like_user.php',
方法:'post',
数据:{post_id:post_id},
成功:功能(数据){
$('').html('hello');
}
})
}
您可以这样做:
<img class="thumb_icon" />
<script>
$(".thumb_icon").mouseover(function(){
var post_id=<?php echo $post_id ?>;
$.ajax({
url:'ajax_like_user.php',
method:'post',
data:{post_id:post_id},
success:function(data){
$('<?php echo '#'.$post_id.'like_user_wrapper' ?>' ).html('hello');
}
})
})
</script>
$(“.thumb_图标”).mouseover(函数(){
var post_id=;
$.ajax({
url:'ajax_like_user.php',
方法:'post',
数据:{post_id:post_id},
成功:功能(数据){
$('').html('hello');
}
})
})
或
函数mouseoverImg(){
var post_id=;
$.ajax({
url:'ajax_like_user.php',
方法:'post',
数据:{post_id:post_id},
成功:功能(数据){
$('').html('hello');
}
})
}
您可以这样做:
<img class="thumb_icon" />
<script>
$(".thumb_icon").mouseover(function(){
var post_id=<?php echo $post_id ?>;
$.ajax({
url:'ajax_like_user.php',
method:'post',
data:{post_id:post_id},
success:function(data){
$('<?php echo '#'.$post_id.'like_user_wrapper' ?>' ).html('hello');
}
})
})
</script>
$(“.thumb_图标”).mouseover(函数(){
var post_id=;
$.ajax({
url:'ajax_like_user.php',
方法:'post',
数据:{post_id:post_id},
成功:功能(数据){
$('').html('hello');
}
})
})
或
函数mouseoverImg(){
var post_id=;
$.ajax({
url:'ajax_like_user.php',
方法:'post',
数据:{post_id:post_id},
成功:功能(数据){
$('').html('hello');
}
})
}
您可以这样做:
<img class="thumb_icon" />
<script>
$(".thumb_icon").mouseover(function(){
var post_id=<?php echo $post_id ?>;
$.ajax({
url:'ajax_like_user.php',
method:'post',
data:{post_id:post_id},
success:function(data){
$('<?php echo '#'.$post_id.'like_user_wrapper' ?>' ).html('hello');
}
})
})
</script>
$(“.thumb_图标”).mouseover(函数(){
var post_id=;
$.ajax({
url:'ajax_like_user.php',
方法:'post',
数据:{post_id:post_id},
成功:功能(数据){
$('').html('hello');
}
})
})
或
函数mouseoverImg(){
var post_id=;
$.ajax({
url:'ajax_like_user.php',
方法:'post',
数据:{post_id:post_id},
成功:功能(数据){
$('').html('hello');
}
})
}
我认为您需要这样做:
HTML:
我认为你需要这样做:
HTML:
我认为你需要这样做:
HTML:
我认为你需要这样做:
HTML:
不要使用内联事件!在JavaScript中正确绑定事件<代码>$('.thumb_icon').mouseover(function(){})
不要使用内联事件!在JavaScript中正确绑定事件<代码>$('.thumb_icon').mouseover(function(){})
不要使用内联事件!在JavaScript中正确绑定事件<代码>$('.thumb_icon').mouseover(function(){})
不要使用内联事件!在JavaScript中正确绑定事件<代码>$('.thumb_icon').mouseover(function(){})
哦,天哪,我甚至不知道这件事会影响选择。不过还是要谢谢你!哦,天哪,我甚至不知道这件事会影响选择。不过还是要谢谢你!哦,天哪,我甚至不知道这件事会影响选择。不过还是要谢谢你!哦,天哪,我甚至不知道这件事会影响选择。不过还是要谢谢你!