开发者

js migrate question

开发者 https://www.devze.com 2023-04-09 09:31 出处:网络
When I moved a paragraph of javascript code from a php file to a individual js file, the js doesn\'t work anymore.

When I moved a paragraph of javascript code from a php file to a individual js file, the js doesn't work anymore.

I just simplely removed the "script" tag and paste all the js code into js file. Did I missing some codes or tags?开发者_如何学JAVA

The code is

<script>
_i = <?=$k+1?>;

function  addlng() {
_id = "lang_"+_i;
$j("#lang_area").append("<div class='lang_addition' id="+_id+"></div>");
$j("#s_lang").clone().appendTo("#"+_id);
$j("#"+_id).append('<span><a href="javascript:void(0)" >&nbsp;<img id="addlng" class="addlng" 
src="<?=style_url('mvl/images/').'bullet_blue_collapse.png'?>" 
onclick="javascript:sub_img(\''+_id+'\');" /></a></span>');
_i++;

}

function sub_img(obj) {
$j("#"+obj).remove(); 

}
</script>


<?=$k+1?> is php. It outputs the value currently in $k+1. You'll have to look in the php to see what $k is. You'll likely need to keep this in your php file:

<script type="text/javascript">
    var _i = <?=$k+1?>;
</script>

Then remove that line for your .js file and make sure that you include your .js file later in your HTML than that script outputted by php.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号