【问题标题】:Using Brython to add hyperlinks to HTML table使用 Brython 向 HTML 表格添加超链接
【发布时间】:2020-07-13 08:40:23
【问题描述】:

我正在尝试向 Brython-HTML 中第一列中的元素添加超链接:

这是 HTML 部分:

<div id="zone">Table</div>

这是 Brython 部分:

        <script type="text/python" id="script7">

        from browser import document
        from browser.html import TABLE, TR, TH, TD
        table = TABLE()
        row = TR() # create a row
        # add header cells
        row <= TH("Header1")
        row <= TH("Header2")
        table <= row # add the row to the table

        lines = [ ['Morrissey','vocals'],
        ['Johnny Marr','guitar'],
        ['Mike Joyce','the drums'],
        ['Andy Rourke','the bass guitar']
        ]
        
        for line in lines:
            table <= TR(TD(line[0], href='http://www.python.org')+TD(line[1]))

        document['zone'].text = ''
        document['zone'] <= table


        </script>

我可以在浏览器中看到表格,但是没有超链接可以点击打开页面。

任何帮助将不胜感激。

问候, 贝鲁兹

【问题讨论】:

    标签: html web brython


    【解决方案1】:

    我通过改变解决了它

    table <= TR(TD(line[0], href='http://www.python.org')+TD(line[1]))
    

    table <= TR(A(line[0], href='http://www.python.org')+TD(line[1]))
    

    现在看起来像:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-20
      • 2020-02-07
      • 2016-01-04
      • 1970-01-01
      • 2013-09-09
      • 2020-05-08
      • 1970-01-01
      • 2014-12-03
      相关资源
      最近更新 更多