मेरे पास ऐसा HTML कोड है।jQuery लक्ष्य वर्ग अलग से
<!-- Every time string is different -->
<span class="time_string">123456789</span>
<span class="time_string">981251100</span>
<span class="time_string">051036626</span>
<span class="time_string">016165656</span>
मैं jQuery के समय स्ट्रिंग को बदलने तिथि करने के लिए
<!-- Look every date is different -->
<span class="time_string">25 March 2017</span>
<span class="time_string">28 April 2017</span>
<span class="time_string">14 January 2017</span>
<span class="time_string">21 December 2015</span>
ऐसा करने के लिए मैं का इस्तेमाल किया है इस jQuery कोड हैं:
<script type="text/javascript">
function timestr_to_date(time_string){
// this function will convert the time string to date
}
$(document).ready(function(){
// getting the time string
var time_string = $('.time_string').html();
// converting the time string to date by using function
var date = timestr_to_date(time_string);
// replacing the time_string to date
$('.time_string').html(date);
});
</script>
लेकिन यह मुझे मिल गया प्रत्येक तारीख
<!-- PROBLEM: Every date are same -->
<span class="time_string">25 March 2017</span>
<span class="time_string">25 March 2017</span>
<span class="time_string">25 March 2017</span>
<span class="time_string">25 March 2017</span>
हम्म .. क्योंकि पर कोई सीमा नहीं है और मुझे नहीं पता कि मेरे पास कितना होगा। मैं उनको उत्पन्न करने के लिए PHP का उपयोग करूंगा। और कोई निश्चित संख्या नहीं होगी – JaTurna
यहां आईडी के लिए कोई आवश्यकता नहीं है। कक्षाएं इसके लिए प्रीफेक्ट हैं क्योंकि यह तत्वों की संख्या को सीमित नहीं करती है, या भविष्य के रखरखाव की आवश्यकता नहीं होती है –
@JaTurna आह मैं देखता हूं कि यह काफी उचित है :) मेरी टिप्पणी को हटा देगा: डी – ThisGuyHasTwoThumbs