jQuery + brython

56 views
Skip to first unread message

Bakalov Daniil

unread,
Sep 9, 2016, 3:16:13 AM9/9/16
to brython
Hi all!!

I started using brython and I really like it! I don't like JS because of its syntax, and I'm glad that there are brython!

I have a question about how to work with Jquery there's a source and I would like to know how it will look in brython?

$("div").attr("id", function (arr) {
 return "div-id" + arr;
})
.each(function () {
 $("span", this)
 .html("(ID = '<strong>" + this.id + "</strong>')");
});

Thank you!
Message has been deleted
Message has been deleted

Bakalov Daniil

unread,
Sep 9, 2016, 3:34:16 AM9/9/16
to brython
$("#button_on").click(function () {
    $('input')
    .removeAttr("disabled")
    .focus()
    .val("Можно редактировать!");
    return false;
});

Bakalov Daniil

unread,
Sep 9, 2016, 5:21:04 AM9/9/16
to brython
i find solution

_$('#button_on').click(lambda: _$('#edit').removeAttr('disabled').focus().val('можно редактировать'))


or

def button_off():
    _$('#edit').attr('disabled', 'disabled').focus().val("Редактировать нельзя!")
    return False
_$('#button_off').click(button_off)

:)

Pierre Quentel

unread,
Sep 11, 2016, 3:36:15 PM9/11/16
to brython

You got it, but this code sure doesn't work : the character $ must raise a SyntaxError.
Reply all
Reply to author
Forward
0 new messages