2017-04-09 3 views

答えて

0

var toReplace = 'No items found'; 
 
var replaceWith = 'We currently have no positions vacant however, please complete an expression of interest form if you would like to join our team'; 
 

 
var div = document.getElementById('accordion'); 
 
if (-1 !== div.innerHTML.indexOf(toReplace)) { // -1 if match not found, else >= 0 
 
    div.innerHTML = replaceWith; 
 
}
<div id="accordion" class="ui-accordion ui-widget ui-helper-reset" role="tablist"> 
 
    No items found. 
 
</div>

+0

ありがとうArvind私は交換される新しいメッセージにリンクを追加しなければならなかったので、タグに奇妙なスタイリングを入れて、コードを少し修正しました。 – Jake

0
var aDiv = document.getElementById("accordion"); 
if (aDiv.innerHTML = " No items found.") 
    aDiv.innerHTML = "We currently have no positions vacant however, please complete an expression of interest form if you would like to join our team"; 
+0

コードはdivの値を変更しますが、#accordian divでジョブリストを有効にしていますが、これが削除され、メッセージに置き換えられます – Jake

+0

http://www.keysolgroup.com.au/join - チーム/欠員 – Jake

0

を「私たちは、現在空いている何のポジションを持っていないあなたが私たちのチームに参加したい場合は、関心のフォームの発現を完了してください。」

var $ = jQuery.noConflict(); 

var accordion = $('#accordion'); 
if(accordion.html() == 'No items found.'){ 
    accordion.html('We currently have no positions vacant however, please complete an expression of interest form if you would like to join our team'); 
} 
1

(function() { 
 
    // Store accordion in a variable because we're using it multiple times 
 
    var accordion = document.getElementById("accordion"); 
 

 
    // Trim any excess white space 
 
    var content = accordion.innerHTML.trim(); 
 

 
    var old_message = "No items found."; 
 
    var new_message = "We currently have no positions vacant however, please complete an expression of interest form if you would like to join our team"; 
 
    
 
    if (content === old_message) { 
 
    accordion.innerHTML = new_message; 
 
    } 
 
}());
<div id="accordion" class="ui-accordion ui-widget ui-helper-reset" role="tablist"> 
 
No items found. 
 
</div>
0:あなたはjQueryのを使用している場合は、単にこれを行うことができます

+0

このコードもありがとう – Jake

0

ねえジェイクは、私は自分自身かなり後輩だが、あなたは以下の内容=のdocument.getElementById(「アコーディオン」)せCONSOLE.LOGしようとするならば、私は思います。それはそれを行う必要がありますinnerHTMLの私がテストするつもりですそれは自分自身を一時的に。

関連する問題