मुझे मेरे साथ div नीचे मिला है जहाँ मुझे पाठ को बदलने की आवश्यकता है Eigth Dollar केवल
<div class="dtls_order_ftr">
<p class="converter">(Total Amount in words: Eigth Dollars only)<br>
<span>(Note: Calculation of taxes and charges made as applicable for individual items)</span>
<span>(Note: Total amount is inclusive of all applicable tax and charges)</span></p>
</div>
मैंने कोशिश की है
var setmyvalue = 'Five Dollars Only'
$(".converter").text(setmyvalue);
लेकिन इसकी पूरी सामग्री की जगह आप कृपया मुझे बता सकते हैं कि यह कैसे करना है ??
http://jsfiddle.net/qfe5xgjs/3/
3 जवाब
इस तरह एक स्पैन प्लेसहोल्डर बनाएं:
<div class="dtls_order_ftr">
<p class="converter">(Total Amount in words: <span id="amountInWords">Eigth Dollars only</span>)<br>
<span>(Note: Calculation of taxes and charges made as applicable for individual items)</span>
<span>(Note: Total amount is inclusive of all applicable tax and charges)</span></p>
</div>
फिर:
var setmyvalue = 'Five Dollars Only'
$("#amountInWords").html(setmyvalue);
$(".converter").text(setmyvalue);
के साथ आप नए मान (setmyvalue)
.. के साथ सभी कनवर्टर को बदलते हैं, इसलिए इसके बजाय यह प्रयास करें
var setmyvalue = 'Five Dollars Only'; // value we want to change to
var replacevalue = $(".converter").text().replace('Eigth Dollars only',setmyvalue); // replace the old value with the new one
$(".converter").text(replacevalue); // put it in the converter after replace it
आपको .replace()
का उपयोग करने की आवश्यकता है, फिर आप container
टेक्स्ट को JS Fiddle सेट करें। strong>
var setmyvalue = 'Five Dollars Only',
text = $(".converter").text();
text = text.replace('Eigth Dollars only', setmyvalue);
$(".converter").text(text);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<div class="dtls_order_ftr">
<p class="converter">(Total Amount in words: Eigth Dollars only)
<br>
<span>(Note: Calculation of taxes and charges made as applicable for individual items)</span>
<span>(Note: Total amount is inclusive of all applicable tax and charges)</span>
</p>
</div>
संबंधित सवाल
नए सवाल
jquery
jQuery एक जावास्क्रिप्ट लाइब्रेरी है, जावास्क्रिप्ट टैग को जोड़ने पर भी विचार करें। jQuery एक लोकप्रिय क्रॉस-ब्राउज़र जावास्क्रिप्ट लाइब्रेरी है, जो दस्तावेज़ ऑब्जेक्ट मॉडल (DOM) ट्रैवर्सल, इवेंट हैंडलिंग, एनिमेशन और AJAX इंटरैक्शन को ब्राउज़रों की विसंगतियों को कम करके सुविधाजनक बनाता है। JQuery से संबंधित एक प्रश्न jQuery से संबंधित होना चाहिए, इसलिए jQuery को प्रश्न में कोड द्वारा उपयोग किया जाना चाहिए और कम से कम jQuery के उपयोग से संबंधित तत्वों को प्रश्न में होना चाहिए।