开发者

jQuery plugin jGrow not working

I have the following code, in which jGrow is not working. I have included Javascript jGrow file. Textarea doesn't adjusts its size according to lengtht of text, instead a scrollbar appears in textarea

<html><head>
<title>jGrow</title>
<script src="jquery.js" type="text/javascript"></script>
<script src="jgrow.js" type="text/javascript"></script>
<script type="text/javascript">
$("textarea#sampl开发者_运维知识库e1").jGrow({
max_height: "300px"
});
</script>
</head>


<body>
<form>
<textarea id="sample1">Jgrow</textarea>
<input type="submit">
</form>
</body>

</html>   


Have you tried debugging with for example Firebux in Firefox? I suspect jGrow hasn't been loaded yet before you are calling it. Solution is to wrap your call into $(document).ready(function() {/* your code */});

<html><head>
<title>jGrow</title>
<script src="jquery.js" type="text/javascript"></script>
<script src="jgrow.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
    $("textarea#sample1").jGrow({
    max_height: "300px"
    });
});
</script>
</head>


<body>
<form>
<textarea id="sample1">Jgrow</textarea>
<input type="submit">
</form>
</body>

</html>  
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜