我在下面的行上收到一条警告:'str'对象不可调用.
有什么办法可以让警告消失吗?
谢谢
Action.action()
Run Code Online (Sandbox Code Playgroud)
这是代码块:
Action = DefineAction()
Action.action()
class DefineAction:
def action(self):
self.action = listAction[generateRandomNumber(0,4)]
return self.action
Run Code Online (Sandbox Code Playgroud)
这是listAction:
listAction =['walks','runs','jaunts','ambles','dashes','sprints']
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个textarea值数组,然后循环它们.
这是一个jsFiddle,我试图让这个工作:
当我运行它时,没有任何反应.
知道我做错了什么吗?
var textArray = [];
$('[class=objectives]').each(function (i) {
textArray.push($(this).val());
});
for (var i = 0; i < textArray.length; i++) {
console.log(textArray[i].value);
}
Run Code Online (Sandbox Code Playgroud) 这个问题涉及我之前提出的另一个问题.
我的页面上有一堆文本框对,每个对都有一个与之关联的图像.单击时,此图像应隐藏自身,并使该对文本框成为只读.
第一部分有效,它确实隐藏了自己.但第二部分不起作用.
我无法弄清楚如何"找到"最接近被点击图像的文本框对.
这是我的jQuery:
$("body").on('click', '.pageLinks img.save', function () {
$(this).hide();
$(this).prevAll('input').each(function () {
$(this).attr('readonly', 'readonly');
});
Run Code Online (Sandbox Code Playgroud)
这是我的HTML:
<div class="pageLinks">
<div>
<div>
<input type="text" class="firstName">
<input type="text" class="lastName">
</div>
<div>
<img src='/saveLink.png' class='save' />
</div>
</div>
<div>
<div>
<input type="text" class="firstName">
<input type="text" class="lastName">
</div>
<div>
<img src='/saveLink.png' class='save' />
</div>
</div>
<div>
<div>
<input type="text" class="firstName">
<input type="text" class="lastName">
</div>
<div>
<img src='/saveLink.png' class='save' />
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
SELECT
*, COUNT(examID) AS ExamCount
FROM
ExamSession
GROUP BY
[examID], [userID], [sessionID]
Run Code Online (Sandbox Code Playgroud)
这给了我一个结果集,但是ExamCount每行中都有一个'1',即使考试显示在一行以上......我试图得到examID结果集中出现的次数.
所以结果集看起来像这样:
examID | userID | sessionID | ExamCount
---------------------------------------------------------
1111 | xxxxxx | xxxxxx | 1
1111 | xxxxxx | xxxxxx | 1
1111 | xxxxxx | xxxxxx | 1
2222 | xxxxxx | xxxxxx | 1
2222 | xxxxxx | xxxxxx | 1
3333 | xxxxxx | xxxxxx | 1
3333 | xxxxxx | xxxxxx | 1
3333 | xxxxxx | xxxxxx …Run Code Online (Sandbox Code Playgroud) 我正在尝试为一组复选框获取一串ID.下面的代码确实包含ID,但它也包含空格和双重逗号,用于未选中的复选框.
有没有办法获得一串只有ID?
谢谢!
$($('input[type=checkbox][name=selector]')).each(function () {
var sThisVal = (this.checked ? this.id : "");
sList += (sList == "" ? sThisVal : "," + sThisVal);
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个返回特定类型的所有对象的linq查询.
如果我想要购买轿车的所有车型,这样的工作会有用吗?
Dim cars = From c In carFactory.GetAllcars()
Select car = carFactory.GetAuto(c.ID)
Where TypeOf (car) Is Sedan
Run Code Online (Sandbox Code Playgroud) 我点击时试图获取链接的ID.我不希望链接去任何地方,我只想要ID.
到目前为止,代码没有向控制台写任何内容.我不确定我做错了什么.
这是我的代码:
$("#webLinks a").on('click', function () {
console.log('clicked: ' + a.id);
});
<div id="webLinks">
<div class="linkRows">
<div name="link1">
<a id="webLink1" href="#" name="www.google.com">Google</a>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
谢谢
我正在尝试捕获页面上的文本框对的值.
我正在捕捉它们,但它并没有按照我想要的方式工作,因为我正在获取重复数据.
这是我的HTML代码:
<div id="links">
<div id="group1">
<input type="text" name="linkTitle" value="Google">
<input type="text" name="linkURL" value="www.google.com">
</div>
<div id="group2">
<input type="text" name="linkTitle" value="Yahoo">
<input type="text" name="linkURL" value="www.Yahoo.com">
</div>
</div>
<div>
<input id="btnSaveLinks" type="button" value="Save">
</div>
Run Code Online (Sandbox Code Playgroud)
这是javascript:
$("#btnSaveLinks").on('click', function() {
$('#links input[type=text]').each(function () {
var title = $(this).attr("value");
var url = $(this).attr("value");
console.log('title: ' + title);
console.log('url: ' + url);
});
});
Run Code Online (Sandbox Code Playgroud)
标题:谷歌
网址:谷歌
标题:www.google.com
网址:www.google.com
标题:雅虎
网址:雅虎
标题:www.yahoo.com
网址:www.yahoo.com
我们使用Autofac在我们的Web应用程序中执行一些简单的依赖注入.它都是在幕后操作的类中配置和注册的.它使得我们项目中的注入东西很容易,就像这样:
//interface
public interface ISuperHereService
{ }
//class that uses the interface
public class SuperHeroFactory
{
public ISuperHeroService SuperHeroService { get; }
public SuperHeroFactory(ISuperHeroService superHeroService)
{
SuperHeroService = superHeroService;
...do all our stuff...
Run Code Online (Sandbox Code Playgroud)
但是现在我不得不创建一个单独的项目作为控制台应用程序.我的控制台应用程序有一个Main方法.
我完全不确定如何在Main方法中注入接口.
这可能吗?
谢谢!
我在使用我的后端代码很好地使用静态main方法时遇到了麻烦.
这是后端的东西:
public interface ITicketGenerationService
{
string CreateTicket(DateTime begin, DateTime end);
}
public class TicketGenerationService : ITicketGenerationService
{
public static IRepository<Ticket> Repository { get; set; }
public TicketGenerationService(IRepository<Ticket> repository)
{
Repository = repository;
}
public string CreateTicket(DateTime begin, DateTime end)
{
//do stuff with Repository
//return status string to Main method
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的控制台应用程序开始的地方:
public class TicketMain
{
public ITicketGenerationService TicketGenerationService { get; set; }
static void Main(string[] args)
{
var priorityOneTickets = TicketGenerationService.CreateTicket(begin, end);
}
}
Run Code Online (Sandbox Code Playgroud)
所以我最初得到这个错误:
非静态字段,方法或属性'TicketMain.TicketGenerationService'需要对象引用
如果我将CreateTicket更改为静态,我会收到另一个错误: …
jquery ×5
javascript ×3
.net ×2
c# ×2
autofac ×1
c#-4.0 ×1
linq ×1
pycharm ×1
python ×1
python-3.x ×1
sql ×1
sql-server ×1
t-sql ×1
vb.net ×1