[英]Jquery find each dynamically generated select inside div and add class to select if option value is “ ”
[英]jquery select div class inside a form and add value
我的模態中有一個表單,可以選擇如下形式:
$(".my-modal").click(function () {
var app_modal = $(this).next('.modal').modal({backdrop: 'static'})
var frm = app_modal.next('.myform')
console.log(frm)
frm.on('submit', function(event){
event.preventDefault();
frm.class('.result').html('<div>Hellooww</div>');
});
我的形式是:
<form class="myform">
<div class="results"></div>
some form element
</form>
在這里,我想在類.results
上放置一些html
,但是我無法做到這一點。. form loop in django template
處於form loop in django template
我怎樣才能做到這一點 ??
jQuery沒有.class()
函數。 如果結果元素是以下形式的后代,則可以使用.find()
:
frm.find('.result').html('<div>Hellooww</div>');
如果result元素是表單的同級元素,則可以轉到父級並找到它,如下所示
frm.parent().find('.result').html('<div>Hellooww</div>');
這可能起作用:
frm.children(".results").html('<div>Hellooww</div>');
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.