我有一個html文件,它有一個用於編寫mdxquery的部分,文件將查詢發送到一個js文件,該文件使用這個查詢和其他信息並在我的html文件中顯示一個地圖,知道我需要通過選擇不同的複選框來自動更改這個mdxqueries,我爲不同的選擇定義了不同的查詢(我的selectins被限制),現在我想在div部分替換它們,因爲我定義了不同的div(就像你會看到潛水是特別是它們的內容是在div標籤裏面,並且是不可更改的),現在問題在於,js文件只讀取了特定div的查詢,因此我需要更改div的id,這裏是我的鱈魚不工作,請看代碼並告訴我什麼是錯的:用javascript的jquery改變div的id
<div class="first" style="width:80%;" id="mdxQueryEditor"
dojoType="GeoSOA.Spatialytics.widgets.MdxQueryEditor" title="MDX query editor"
submitButtonLabel="Submit"
mdxQuery="SELECT {[Measures].[report]} ON COLUMNS,
{[State].[City].members} ON
ROWS
FROM [ppgis]">
</div>
<div id="" class='second' dojoType='GeoSOA.Spatialytics.widgets.MdxQueryEditor' style='width:100%;display:none;'
mdxQuery='SELECT {[Measures].[report]} ON COLUMNS,
{[Boston].[City].members} ON ROWS
FROM [ppgis]'
submitButtonLabel='Submit'></div>
<div id="" class='third' dojoType='GeoSOA.Spatialytics.widgets.MdxQueryEditor'
style='width:80%;display:none;' mdxQuery='SELECT {[Measures].[report]} ON COLUMNS,
{([State].[All States].
[Boston].[Allston/Brighton], [Subject].[All Subjects])} ON ROWS
FROM [ppgis]'
submitButtonLabel='Submit'></div>
<script>
function generatorChoice(){
if(($("#Allston").is(":checked"))&&(!$("#All State").is(":checked")) && (!$("#Boston").is(":checked"))){
/*When the checkbox is checked*/
$(".first").attr("id", "");
$(".third").attr("id", "mdxQueryEditor");
$('.first').css('display','none');
$('.second').css('display','none');
$('.third').css('display','block') ;
}
}
</script>
謝謝,但我測試我的代碼,它只是工作,它不能改變的ID,因此不顯示地圖,我 – neda
@neda你怎麼說它正在工作。我測試了你的jQuery代碼Id正在更新,請檢查這個鏈接 - [鏈接] http://jsfiddle.net/g6HVk/。 **我仍然看到如果條件不成功**,你有更新嗎?你能發佈更新後的代碼嗎? – SridharVenkat