jquery - PHP - How to Check if Anchor Tag is Empty? -
how can check if anchor tag empty php or preg_match or jquery? example if achor tag looks like: <a href="some_url"></a> want skip on it.
i trying add database functionality superfish menu in google chrome empty anchor tags in sub-menus. in other browsers works fine.
i can't figure out problem thought if not output empty anchors might work.
can help?
thank you!
<?php //--------------------------------------------------------------- // include db connection //--------------------------------------------------------------- require_once(root_path.'connections/mysql.php'); require_once(root_path.'controls/menu/error_messages.php'); //--------------------------------------------------------------- // menu db //--------------------------------------------------------------- $get_menu = mysqli_query($conn, "select menuid, url, target, label, title, description, parentid, ordinalposition, isenabled menu (isenabled = 1) order parentid, ordinalposition, label") or die($dataaccess_error); if(mysqli_num_rows($get_menu) > 0) { // loop through menu items while ($menu_item = mysqli_fetch_assoc($get_menu)) { $menu_data['menuitem'][$menu_item['menuid']] = $menu_item; $menu_data['menuparent'][$menu_item['parentid']][] = $menu_item['menuid']; } } else { echo $no_menu_items_error; } //--------------------------------------------------------------- // build menu function superfish //--------------------------------------------------------------- function horizmenu($parent_id, $menu_data) { $html = ''; if (isset($menu_data['menuparent'][$parent_id])) { $html = '<ul class="sf-menu">'; foreach ($menu_data['menuparent'][$parent_id] $itemid) { // menu variables $url = $menu_data['menuitem'][$itemid]['url']; $target = $menu_data['menuitem'][$itemid]['target']; $title = $menu_data['menuitem'][$itemid]['title']; $label = $menu_data['menuitem'][$itemid]['label']; $html .= '<li class="current"><a href="'.$url.'" target="'.$target.'" title="'.$title.'">'.$label; // find childitems recursively $html .= horizmenu($itemid, $menu_data); $html .= '</a></li>'; } $html .= '</ul>'; } return $html; } // output menu echo horizmenu(0, $menu_data); ?>
this should taken care of javascript (jquery). can use jquery's "each" method follows:
$('a').each(function(index) { if( $(this).attr('href') == [something] ) { //do } });
Comments
Post a Comment