extract line from javascript
I need to extract this line of code from a script i am retrieving via ajax..
this line new Date(2010, 10 - 1开发者_运维技巧, 31, 23, 59, 59)
from
jQuery(function () { jQuery('#dealCountdown').countdown({
until: new Date(2010, 10 - 1, 31, 23, 59, 59),
serverSync: serverTime,
timezone: +11,
compact: true,
format: 'HMS',
expiryUrl: BASE,
layout: '
Is it possible to do this with jquery. The jquery selector won't let me manipulate script tags.
Any help would be greatly appreciated.
Use javascript's native function String.match
:
importantline = "" + ajax_data.match(/until:\s.*,/);
importantline = importantline.replace(/^until:|,$/gi, "");
importantline
should have the string you need
I added a jsfiddle to make clear it works: http://jsfiddle.net/elektronikLexikon/3eZAf/
精彩评论