我在一个输入字段上使用自动完成功能来填充另一个输入字段:
<input id='fruit' name='fruit' type='text'>
<input id='details' name='details' type='text'>
Run Code Online (Sandbox Code Playgroud)
jQuery代码:
var x = ["apple", "kiwi", "lemon"];
$( "#fruit" ).autocomplete({
source: x
});
jQuery(document).on("change","#fruit", function()
{
$.each(x, function(key, value) {
switch(value) {
case "apple":
$('#details').val("Delicious");
break;
case "kiwi":
$('#details').val("Yummy");
break;
case "lemon":
$('#details').val("Sour");
}
});
});
Run Code Online (Sandbox Code Playgroud)
当有人用自动完成选择苹果,猕猴桃或柠檬时,它会用相应的文本填写另一个输入字段.
我有两个问题:
这是一个小提琴
我有一个包含简单付款方式的组件.我只想获取当前菜单项ID.我已经尝试了几件事来获取身份证.
//get the active menu item id
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive();
$activeId = $active->id;
JLog::add('active id is: '.$activeId); //I get nothing returned
$currentMenuId = JSite::getMenu()->getActive()->id ;
JLog::add('menu id is: '.$currentMenuId); //I get nothing returned
//try to see what the current url is
$currenturl = JURI::current();
JLog::add('current url is: '.$currenturl); //I get mysite.com/index.php
Run Code Online (Sandbox Code Playgroud)
我$activeId在我的插件中使用代码没有问题,但它在我的组件中不起作用.我错过了什么?
如果可以向onmouseover添加文本,我似乎无法找到参考
因此,我想为"监视器"按钮的onmouseover添加一个简单的提示.
<input type="submit" name="video" value="Monitor" />
Run Code Online (Sandbox Code Playgroud) 我一直以不同的方式创造元素,我不确定最好的方法.有什么区别:
var myselect = document.createElement("select");
myselect.name="blah";
Run Code Online (Sandbox Code Playgroud)
和
var myselect = document.createElement("select");
myselect.setAttribute("name", "blah");
Run Code Online (Sandbox Code Playgroud)
我最近刚刚使用以下方式绊倒了:
var label = document.createElement("label");
label.for= "blah";
Run Code Online (Sandbox Code Playgroud)
哪个不起作用,我不得不使用setAttribute.是否有优势/劣势?
不知道我在这里做错了什么.只是想让它成为一个模态对话框(使页面内容变暗).我觉得它很简单modal:true.单击图像时会出现一个对话框,但不会使页面内容变暗.
<img src="images/help-35-30.png" alt="Help" class="helpdetails" style="padding-left:30px;"/>
<div class="dialogplease"><p>A comment</p></div>
<link rel="stylesheet" type="text/css" href="mycss/css/jquery-ui-1.8.20.custom.css" />
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script language="javascript" type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.20/jquery-ui.js"></script>
<script>
$(function() {
$('.dialogplease').dialog(); //init dialog
$('.dialogplease').dialog('close'); //don't show dialog yet
$('.helpdetails').click(function(e) {
$('.dialogplease').dialog('open')({
modal: true
});
});
});
</script>
Run Code Online (Sandbox Code Playgroud) 我有一行我添加一些CSS:
$("#foo").html("Some text with a link <a href=\"link.html\">Link here</a>").css({
'margin': '10px 0px',
'padding': '15px 10px 15px 50px',
'clear': 'left'
});
Run Code Online (Sandbox Code Playgroud)
我想将链接更改为黑色,因此添加此css应该有效:
a.link {
color: black
}
Run Code Online (Sandbox Code Playgroud)
我想最好的办法是指向一个css文件而不是添加a.link.但想知道是否有可能.显然这样的东西不起作用,因为它不是正确的json格式:
$("#foo").html("Some text with a link <a href=\"link.html\">Link here</a>").css({
'margin': '10px 0px',
'padding': '15px 10px 15px 50px',
'clear': 'left',
'a:link: color': 'black'
});
Run Code Online (Sandbox Code Playgroud)
有没有办法做到这一点?