[英]Can't disable the title select2 in 2 modal
I have 2 modal at same page using select2.我使用 select2 在同一页面上有 2 个模态。 I need to remove title on hover select2 in modal select form.
我需要在模态选择表单中删除悬停 select2 上的标题。 I have tried
我试过了
$('.select2-selection__rendered').hover(function () {
$(this).removeAttr('title');
});
to remove the hover, but it only works in 1 modal.删除悬停,但它仅适用于 1 模态。 In the other modal at the same page, it still show hover title.
在同一页面的另一个模态中,它仍然显示悬停标题。
Here's the script modal 1这是脚本模式 1
<div class="form-group" id="form-class-1" style="margin-top: -10px">
<div class="row">
<div class="col">
<div class="row">
<div class="col">
<label for="class">Class *</label>
<div class="row">
<div class="col">
<select id="class" class="form-control" name="class" style="width: 100%">
<option value="" selected disabled>-- Choose Class --</option>
<?php
foreach ($class $c)
{
echo '<option value="'.$c->id.'">'.$c->class_name.' </option>';
}
?>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Here's the script modal 2这是脚本模式 2
<div class="form-group" id="form-class-2" style="margin-top: -10px">
<div class="row">
<div class="col">
<div class="row">
<div class="col">
<label for="class">Class*</label>
<div class="row">
<div class="col">
<select id="clas" class="form-control" name="clas" style="width: 100%">
<option value="" selected disabled>-- Choose Class --</option>
<?php
foreach ($class $c)
{
echo '<option value="'.$c->id.'">'.$c->class_name.' </option>';
}
?>
</select>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
Every help is appreciated.每一个帮助表示赞赏。
With your JS condition it only select the modal where it's hover because of $(this)使用您的 JS 条件,它只选择它悬停的模态,因为 $(this)
$('.select2-selection__rendered').hover(function () {
$(this).removeAttr('title');
});
you should change it to $( class of modal1 and modal2 ).removeAttr('title');
您应该将其更改为
$( class of modal1 and modal2 ).removeAttr('title');
also why the two modal have the same id in the same page id="form-kelas1"
?还有为什么两个模态在同一页面
id="form-kelas1"
具有相同的 id ?
id should be unique per page.每页的 id 应该是唯一的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.