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>
精彩评论