简体   繁体   English

从javascript提取行

[英]extract line from javascript

I need to extract this line of code from a script i am retrieving via ajax.. 我需要从我通过Ajax检索的脚本中提取这行代码。

this line new Date(2010, 10 - 1, 31, 23, 59, 59) from 这行new Date(2010, 10 - 1, 31, 23, 59, 59)

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. 是否有可能用jQuery做到这一点。 The jquery selector won't let me manipulate script tags. jQuery选择器不允许我操作脚本标签。

Any help would be greatly appreciated. 任何帮助将不胜感激。

Use javascript's native function String.match : 使用javascript的本机函数String.match

importantline = "" + ajax_data.match(/until:\s.*,/);
importantline = importantline.replace(/^until:|,$/gi, "");

importantline should have the string you need importantline应该有您需要的字符串

I added a jsfiddle to make clear it works: http://jsfiddle.net/elektronikLexikon/3eZAf/ 我添加了一个jsfiddle来明确说明它的工作原理: http : //jsfiddle.net/elektronikLexikon/3eZAf/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM