Closed. This question needs details or clarity。它当前不接受答案。
                        
                    
                
            
        
            
        
                
                    
                
            
                
                    想改善这个问题吗?添加详细信息并通过editing this post阐明问题。
                
                    5年前关闭。
            
        

    

我正在尝试从称为divobjPath到代码的JavaScript部分获取值,但格式错误,如下所示:

uploads/function(e){return x.access(this,function(e){var n=this[0]||
{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(gt,"")
:t;if(!("string"... and so on


有什么办法可以使它更好吗?

<div class="page product-details-page">
<div class="page-body">
    @using (Html.BeginRouteForm("Product", new { SeName = Model.SeName }, FormMethod.Post, new {    id = "product-details-form" }))
    {

<div id="objPath">  @Model.ObjPath</div>
<div id="texturePath">  @Model.TexturePath</div>

    }

</div>
</div>
<div>

    <script src="js/build/three.min.js"></script>
    <script type="text/javascript">

        var objPath = $("#objPath").html;
        var str1 = "uploads/";
        var resObjPath = str1.concat(objPath);
        init();

        function init() {

            var loader = new THREE.OBJLoader(manager);
            loader.load(resObjPath, function (object) {

最佳答案

由于您已经在使用jQuery,因此对于objPath,您几乎已经正确了。

要获取div中包含的文本值,您需要

var objPath = $("#objPath").text();

而不是

var objPath = $("#objPath").html;

09-12 15:03