在我编写的第二个jQuerys之间没有工作。
我认为这是jQuery冲突的情况。
请帮忙......
<script>
//this is the first jQuery code
jQuery( document ).ready(function( $ ) {
$(function() {
$(document).ready(function(){
$('.rm option').each(function(){
if($(this).text()==$('div#disp').text())
$(this).attr('selected','selected');
});
});
//this is the second jQuery code
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 800
},
hide: {
effect: "blind",
duration: 500
}
});
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
}); $(function () { $('#dialog').dialog({ keyboard: true })});
</script>
答案 0 :(得分:0)
试试这个:
<script type='text/javascript'>
$(document).ready(function(){
$.each($('.rm option'), function( index, value ) {
if( $(this).text() == $('div#disp').text() ){
$(this).attr('selected','selected');
}
});
$( "#dialog" ).dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 800
},
hide: {
effect: "blind",
duration: 500
},
keyboard: true
});
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
});
</script>
我修复unessesary'}'并删除无用的.ready和函数,并将.each更改为$ .each
PS。编辑,对不起,现在试试。