小编Mom*_*mar的帖子

如何使用PHP删除JS注释?

如何使用PHP删除JS注释?这个问题已更新:2013年11月4日回答:Alexander Yancharuk但是现在有一个问题.新代码:id = id.replace(/\//g,'');

这是我的例子:

<?php
$output = "
//remove comment
this1 //remove comment
this2 /* remove comment */
this3 /* remove
comment */
this4 /* * * remove
* * * *
comment * * */
this5 http://removecomment.com
id = id.replace(/\//g,''); //do not remove the regex //
";

$output = preg_replace( "/(?:(?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:(?<!\:)\/\/.*))/", "", $output ); //Yancharuk's code/regex
// "/(?<!\:)\/\/(.*)\\n/ = my oldest code

echo nl2br($output);
?>
Run Code Online (Sandbox Code Playgroud)

我的问题;

  1. 这一行有问题;
  2. //注释正在运行,但我无法创建代码来删除/*注释*/或带有换行符的注释

这是输出,最近:



this1
this2
this3
this4
this5 http://removecomment.com
ID = …

javascript php

10
推荐指数
3
解决办法
1万
查看次数

如何使用JS或jQuery添加sleep或等待JS?

如何从这个函数ShowSC()添加睡眠

function ShowSC(){
 $("#SC").html('LOADING');
 //adding the sleep 1 second
 $("#SC").html('<img src="secure/captcha/securimage_show.php" class="img_middle" />');
}
Run Code Online (Sandbox Code Playgroud)

提前感谢!

对不起,我找不到其他问题的解决方案,所以我在这里开始提问.

javascript jquery

0
推荐指数
1
解决办法
251
查看次数

如何更改TD的背景图片?

这是我的代码:

JS/jQuery的:

function RefreshImage(){
    var form_data = {
        ID: $('#ID').val()
    };

    $.ajax({
        type: "POST",
        url: "submit/image.php",
        data: form_data,
        success: function(data) {
            $('#IMG').css('backgroundImage', "url('images/+data+')");
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

HTML:

<table>
    <tr>
        <td background="images/default.jpg" id="IMG"></td> 
    </tr>
</table>
<input type="hidden" id="ID" value="4">
Run Code Online (Sandbox Code Playgroud)

CSS:

#IMG{
    background-color:rgba(0,0,0,0.5);
    width:99px; height:99px;
    -webkit-background-size: cover;
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
    vertical-align:text-top;
}
Run Code Online (Sandbox Code Playgroud)

我的代码失败了,因为它只是变为黑色图像.但是在响应中,它显示了我请求的图像名称的确切值,但它失败了,因为它只是变为黑色.

提前谢谢.

javascript jquery

0
推荐指数
1
解决办法
3587
查看次数

标签 统计

javascript ×3

jquery ×2

php ×1