所以我目前有一个带有两个按钮的jQuery对话框:Save and Close.我使用下面的代码创建对话框:
$dialogDiv.dialog({
autoOpen: false,
modal: true,
width: 600,
resizable: false,
buttons: {
Cancel: function() {
// Cancel code here
},
'Save': function() {
// Save code here
}
},
close: function() {
// Close code here (incidentally, same as Cancel code)
}
});
Run Code Online (Sandbox Code Playgroud)
但是,使用此代码时,两个按钮的颜色相同.我希望我的取消按钮与我的保存颜色不同.有没有办法使用一些内置的jQuery选项来做到这一点?我没有从文档中获得太多帮助.
请注意,我正在创建的"取消"按钮是预定义类型,但"保存"我自己定义.不确定这是否会对问题产生任何影响.
任何帮助,将不胜感激.谢谢.
更新:共识是这里有两条道路:
我使用了第二个选项,并使用了jQuery find()方法,因为我认为这比使用更合适:first或:first-child b/c我想要更改的按钮不一定是列出的第一个按钮标记.使用find,我只需指定按钮的名称,并以这种方式添加CSS.我最终得到的代码如下:
$dialogDiv.dialog({
autoOpen: false,
modal: true,
width: 600,
resizable: false,
buttons: {
Cancel: function() {
// Cancel code here
},
'Save': function() …
Run Code Online (Sandbox Code Playgroud) 我正在使用JQuery提交表单.表格如下所示
<form class="ask-more-form">
<div class="product_info_2">
<textarea name="product_question" class="textbox" placeholder="Ask You Question Here"></textarea>
</div>
<input type="hidden" name="product_id" value="1" id="product_id">
<a href="#" class="whiteButton submit" id="ask-more-submit-button">Ask Question</a>
</form>
Run Code Online (Sandbox Code Playgroud)
并且用于捕获表单的JQuery看起来像这样:
$('#ask-more').on('submit', '.ask-more-form', function() {
var product_id = $(this).children('input[name=product_id]').val();
var product_question = $(this).children('textarea[name="product_question"]').text();
alert(product_question);
//submitQuestion(product_id, product_question);
});
Run Code Online (Sandbox Code Playgroud)
始终读取product_id,但产品问题始终为null.谁能告诉我为什么会这样?
来自jquery.ui.autocomplete.js:
_renderMenu: function( ul, items ) {
var self = this;
$.each( items, function( index, item ) {
self._renderItem( ul, item );
});
},
Run Code Online (Sandbox Code Playgroud)