我正在使用jQuery Isotope并尝试使用.... UIPropertyMetadata(new Controller()));
更改div类中的HTML文本,基于if / else:
Dictionary<string, ObservableCollection<Employee>> EmpList = DepList.Select(m => new
{
Dep = m.DepName,
EmpCollection =
m.sortEmpName == SortDirection.Ascending ?
new ObservableCollection<Employee>(m.EmpName.Select(k => new Employee {EmpName = k, IsChecked = true}).ToList().OrderBy(emp => emp.EmpName)) :
m.sortEmpName == SortDirection.Descending ?
new ObservableCollection<Employee>(m.EmpName.Select(k => new Employee { EmpName = k, IsChecked = true }).ToList().OrderByDescending(emp => emp.EmpName)) :
new ObservableCollection<Employee>(m.EmpName.Select(k => new Employee { EmpName = k, IsChecked = true }).ToList())
}).ToDictionary(x => x.Dep, x => x.EmpCollection);
但它点按了按钮changeMe
和var $chofval = $(".changeMe").html(filterAttr);
// search if it contains these strings
if ($chofval.indexOf("*") >= 0) {
$(".changeMe").html("All Apples");
} else if ($chofval.indexOf(".green") >= 0) {
$(".changeMe").html("Green Apples");
}
。我猜错了什么?
完整代码:
*
答案 0 :(得分:0)
if(filterAttr == "*") {
$(".Me").html("All Apples");
}
else if(filterAttr == ".green") {
$(".changeMe").html("Green Apples");
}
答案 1 :(得分:0)
这一行改变了&#34; .changeMe&#34;的内容。使用filterAttr的值,并且不能重新调整&#34; .changeMe&#34;的内容的值。对象
var $chofval = $(".changeMe").html(filterAttr);
如果你想获得&#34; .changeMe&#34;的内容。评估使用:
var $chofval = $(".changeMe").html();
但是如果你试图获得被定义为filterAttr的权利.changeMe属性的值:
var $chofval = $(".changeMe").attr(filterAttr);
或者最后如果filterAttr是要检查的实际值,请在句子中使用此值来评估它:
if(filterAttr.indexOf("*") >= 0){
$(".changeMe").html("All Apples");
} else if(filterAttr.indexOf(".green") >= 0){
$(".changeMe").html("Green Apples");
}
请参阅JQuery Attr