Jquery UI 可调整大小的处理程序
Jquery UI resizable handlers
我正在使用 jQuery UI 可调整大小,我想为每个处理程序设置一个标题。
就像我将鼠标悬停在 'east -handler' 上,然后应该出现一个工具提示说 'that move to the right'。我试图用 jQuery attr()
但做不到。任何帮助表示赞赏。还有一件事我有多个元素,我正在应用可调整大小的方法,所以所有元素都应该得到相同的 "title".
$(document).ready(function() {
$('.ui-icon-gripsmall-diagonal-e').each(function() {
$(this).attr('title', 'hello');
});
});
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Resizable functionality</title>
<link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<!-- CSS -->
<style>
#resizable {
width: 150px;
height: 150px;
padding: 0.5em;
text-align: center;
margin: 0;
}
</style>
<!-- Javascript -->
<script>
$(function() {
$("#resizable").resizable();
});
</script>
</head>
<body>
<!-- HTML -->
<div id="resizable" class="ui-widget-content">
<h3 class="ui-widget-header">Pull my edges to resize me!!</h3>
</div>
</body>
</html>
您需要运行您的代码在您初始化插件之后。像这样:
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Resizable functionality</title>
<link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<!-- CSS -->
<style>
#resizable {
width: 150px;
height: 150px;
padding: 0.5em;
text-align: center;
margin: 0;
}
</style>
<!-- Javascript -->
<script>
$(function() {
$("#resizable").
resizable().
find('.ui-resizable-se').attr('title', 'hello');
});
</script>
</head>
<body>
<!-- HTML -->
<div id="resizable" class="ui-widget-content">
<h3 class="ui-widget-header">Pull my edges to resize me!!</h3>
</div>
</body>
</html>
我正在使用 jQuery UI 可调整大小,我想为每个处理程序设置一个标题。
就像我将鼠标悬停在 'east -handler' 上,然后应该出现一个工具提示说 'that move to the right'。我试图用 jQuery attr()
但做不到。任何帮助表示赞赏。还有一件事我有多个元素,我正在应用可调整大小的方法,所以所有元素都应该得到相同的 "title".
$(document).ready(function() {
$('.ui-icon-gripsmall-diagonal-e').each(function() {
$(this).attr('title', 'hello');
});
});
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Resizable functionality</title>
<link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<!-- CSS -->
<style>
#resizable {
width: 150px;
height: 150px;
padding: 0.5em;
text-align: center;
margin: 0;
}
</style>
<!-- Javascript -->
<script>
$(function() {
$("#resizable").resizable();
});
</script>
</head>
<body>
<!-- HTML -->
<div id="resizable" class="ui-widget-content">
<h3 class="ui-widget-header">Pull my edges to resize me!!</h3>
</div>
</body>
</html>
您需要运行您的代码在您初始化插件之后。像这样:
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Resizable functionality</title>
<link href="https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel="stylesheet">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<!-- CSS -->
<style>
#resizable {
width: 150px;
height: 150px;
padding: 0.5em;
text-align: center;
margin: 0;
}
</style>
<!-- Javascript -->
<script>
$(function() {
$("#resizable").
resizable().
find('.ui-resizable-se').attr('title', 'hello');
});
</script>
</head>
<body>
<!-- HTML -->
<div id="resizable" class="ui-widget-content">
<h3 class="ui-widget-header">Pull my edges to resize me!!</h3>
</div>
</body>
</html>