0

我刚刚从http://www.garralab.com/nailthumb.php下载了 nailthumb 项目,但我不能从 js 的 asp.net mvc 3 调用这个函数。

示例中的函数调用如下:

 <script type="text/javascript">
   jQuery(document).ready(function() {
   jQuery('.nailthumb-container').nailthumb({
   width:100,height:100,method:'resize',fitDirection:'top left'});
   });
</script>

我试过了:

<script type="text/javascript">
    $(document).ready(function () {
    $('#nailthumb-container').nailthumb({
       width: '100',
       height: '100' 
       });

   });
</script>

js文件加载,但我不知道如何调用这个函数。有任何想法吗?

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"> </script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="../../Scripts/jquery.nailthumb.1.1.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.nailthumb.1.1.css" type="text/css"></script>
<script src="@Url.Content("~/Scripts/jquery-1.5.1.js")" type="text/javascript"></script>
<style type="text/css" media="screen">
    .square-thumb {
        width: 150px;
        height: 150px;
    }
</style>

<div class="nailthumb-container square-thumb">
 <img alt='' src='@Url.Action("Show", "ConsultorioImagenes", new { id = Model.ID})' />
</div>
4

2 回答 2

0

当您为它分配一个类时,您正在使用 id 选择器 (#)。

这一行:

<div class="nailthumb-container square-thumb">

..分配 nail-thumb-container 类。您需要在 jQuery 调用中使用类选择器 (.):

<script type="text/javascript">
    $(document).ready(function () {
        $('.nailthumb-container').nailthumb({
           width: '100',
           height: '100' 
         });
   });
</script>
于 2012-08-01T02:53:58.327 回答
0

你有<div class="nailthumb-container square-thumb">

$('#nailthumb-container').nailthumb({

它应该是$('.nailthumb-container').nailthumb({

于 2012-08-01T02:55:44.600 回答