Changing an anchor property on "click" of another anchor item - html

It is possible to change the initial anchor property of one text item when another anchored property text item is clicked without using javascript?
EXAMPLE CODE:
<div class=links>
<ul>
<li>
<a href="#"onclick="MM_showHideLayers('what_we_do','','show');MM_showHideLayers('our_mission','','hide');MM_showHideLayers('who_we_are','','hide')" **class="active"**>WHAT WE DO</a> |
</li>
<li>
<a href="#" onclick="MM_showHideLayers('who_we_are','','hide');MM_showHideLayers('our_mission','','show');MM_showHideLayers('what_we_do','','hide')" class>OUR MISSION</a> |
</li>
<li>
<a href="#" onclick="MM_showHideLayers('our_mission','','hide');MM_showHideLayers('who_we_are','','show');MM_showHideLayers('what_we_do','','hide')" class>WHO WE ARE</a>
</li>
</ul>
</div>
I would like to change the class="active" property in the first string to my default "a" assigned property when either of the other text links are clicked by the user and stay that way until it is clicked again.
Thanks in advance!

I think you'll need to use javascript/jQuery it's not tricky
First give all links the same class for example btn
<a href="#" class="active btn" >WHAT WE DO</a> |
<a href="#" class="btn" >OUR MISSION</a> |
<a href="#" class="btn" >WHO WE ARE</a>
Now add the jQuery:
$('.btn').click(function(){
$('.btn').removeClass('active');
$(this).addClass('active');
});
This script removes the active class from all the anchors and then adds it to whichever anchor has been clicked.
Hope this helps

Related

<span> not starting where it starts where I want it to on new line

In the image you can see that if the title of the sidebar link is too long it goes to the next line. However it starts where the icon is located and not where the start of the span is. How would I style the class "side-nav-item" to where it will format where Administrator when it is shifted to the new line it starts where Give is.
<li class="side-nav-item">
<a data-bs-toggle="collapse" href="#userAccess" aria-expanded="false" aria-controls="userAccess"
class="side-nav-link">
<i class="uil-layer-group"></i>
<span>User Access</span>
<span class="menu-arrow"></span>
</a>
<div class="collapse" id="userAccess" data-bs-parent="#accordion">
<ul>
<li class="side-nav-item">
<a href="/task/add-location-access" class="side-nav-link">
<i class="uil-shield-check"></i>
<span> Give user access - Administrator</span>
</a>
</li>
<li class="side-nav-item">
<a href="/task/remove-location-access" class="side-nav-link">
<i class="uil-shield-slash"></i>
<span> Remove</span>
</a>
</li>
</ul>
</div>
</li>
Style <span> inside <a></a> as an inline-block. The behaviour you are seeing is expected from inline elements like <span> and <i>. Checkout concepts of inline elements, block elements and 'display' property in CSS. I am assuming you are new to HTML and CSS, so I suggest you begin with a good hands on video tutorial.
try this ,
<span
style="width:400px;text-align:start;height:max-content;"
>
Give user access - Administrator
</span>

Tab-Index for absolutely positioned elements in layout

Tab Index for Absolute-Position Elements
For the time being, lets assume I wrote the code below:
<header class="header hap" [ngClass]="authority">
<div class="header-inner">
<div class="header-identity">
<a id="theLogo" class="logo" [routerLink]="[links.home]" title="Navigate to Home">
<img src="assets/logo-white.svg" alt="Logo">
</a>
<span class="client-logo" *ngIf="user.brandingImage && !user.isTheAdmin()">
<img class="brandingImage" [src]="user.brandingImage" [alt]="user.brandingName" onerror="this.style.display='none'">
</span>
[ more links ]
</div>
<nav class="main-nav for authenticated" [ngClass]="{'active':showMenu, 'app-only':!isCurrPageAdminApp()}">
<button class="menu" (click)="toggleMenu()">Menu</button>
<div class="main-nav-flyout" *ngIf="showMenu">
<div class="nav-header">
<ul>
<li>
<a id="main-nav-profile" [routerLink]="['/profile']"><span class="icon icon-user2"></span> My Profile</a>
</li>
[ more dropdown items ]
</ul>
<a id="main-nav-close" class="close"(click)="onClickMenuClose()"><span class="icon-cross"></span></a>
</div>
<div class="nav-body">
<ul *ngIf="isCurrPageAdminApp()" class="main-nav-list">
<li class="current-app">Administrative Tools</li>
<li><a id="main-nav-xAdmin" *ngIf="user.isTheAdmin()" [routerLink]="['admin/x']">X Admin</a></li>
[ more links ]
<li>
<span>Reports</span>
<ul>
<li class="user-status"><a id="main-nav-userStatusReport" [routerLink]="['admin/reports/userStatus']">User Status</a></li>
[ more links ]
</ul>
</li>
</ul>
<ul class="app-list" *ngIf="user.userApplications">
<li *ngIf="showTheLink()">
<a id="app-list-type" [routerLink]="['/']">
...
</a>
</li>
[ more links ]
<li *ngFor="let application of user?.userApplications">
<a id="app-list-{{application.abbreviation}}" *ngIf="!isAdminApp(application)" (click)="onClickMenuItem(application)">
{{ application.title }}
</a>
</li>
</ul>
</div>
</div>
</nav>
<nav class="user-nav for authenticated" role="menu">
<span *ngIf="user.brandingName" class="user-location">{{user.brandingName}}</span>
<span *ngIf="user.brandingName" class="pipe">|</span>
<a id="user-nav-profile" class="user-name" [routerLink]="['/profile']">
<span class="name">{{user?.firstName}} {{user?.lastName}}</span>
</a>
<a id="user-nav-logout" class="logout" [routerLink]="['/', 'logout']">Log out</a>
</nav>
</div>
</header>
Issue
Various elements -- probably .header-inner > * -- are styled using position: absolute;, so the tabindex-order is skewed for elements which are declared later in the markup but positioned geometrically earlier in the layout.
Question
Is there a way to force the tabindex to be, say, all natural indices (0) except for 2 items that need to be switched -- in a scalable way while not having to implement tabindex for every new item in the layout?
The short answer is no, it's not possible to switch only two elements without at least adding tabindex to every element in the flow that has to be focused before those two elements.
All elements with positive tabindex will be focused first in an incremental way, or in their source order if they have the same value, and all elements with default value or zero will be focused last.
So if you have 6 focusable elements and you want to have elements 5 and 6 to be focused after elements 1 and 2, you need something like this:
<input type="text" tabindex="1">1</input>
<input type="text" tabindex="1">2</input>
<input type="text">3</input>
<input type="text">4</input>
<input type="text" tabindex="1">5</input>
<input type="text" tabindex="1">6</input>
In general having the source order match the flow is the easiest way to make it work.
There is one particular case that is simpler. If the elements you want to move happen to be the first elements that need focus on your page, then in that particular case you can put the tabindex only on those elements.
For instance, if we wanted elements 5 and 6 be the first elements on the page, and everything else after them, all you need to do is this:
<input type="text">1</input>
<input type="text">2</input>
<input type="text">3</input>
<input type="text">4</input>
<input type="text" tabindex="1">5</input>
<input type="text" tabindex="1">6</input>
So in general, if the elements you want to change order are in the header, and they are the first things that should be focusable on your page, it should be easy to rearrange them and let the rest of the page flow naturally.
If the elements had to be last you are out of luck, you should either:
Put them last in the markup so they flow naturally
Remove them from the flow with tabindex=-1 and let the user focus manually

element with tabindex 0 to next element with tabindex 1+ is not focused

I am having a HTML template with set of <a> tags. Added tabindex for the elements.
Issue is on clicking tab button to focus, element with tabindex 1+ is not focusing.
Requirement is focus should happen on changing the focus from element with tabindex 0 to an element with tabindex 1+.
<div>
<ul class="gn-filter-anchor-list">
<li>
<a title="Under $25.00" tabindex="0" href="/"><span class="off-screen">from Price</span> Under $25.00</a></li>
<li>
<a title="$25.00-$49.00" tabindex="0" href="/"><span class="off-screen">from Price</span> $25.00-$49.00</a></li>
<li>
<a title="$50.00-$74.00" tabindex="0" href="/"><span class="off-screen">from Price</span> $50.00-$74.00</a></li>
<li>
<a title="$75.00-$99.00" tabindex="0" href="/"><span class="off-screen">from Price</span> $75.00-$99.00</a></li>
<li>
<a title="Over $100.00" tabindex="0" href="/"><span class="off-screen">from Price</span> Over $100.00</a></li>
</ul>
</div>
<div >
<div class="dept-large">xxx</div>
<div class="dept-large">xxx</div>
<div class="dept-large">xxx</div>
</div>
<div >
<ul class="pagination" >
<li class="current"><a href="#" >1</a></li>
<li class="odd first"><a href="#" >2</a></li>
<li class="even"><a href="#" >3</a></li>
<li class="odd"><a href="#" >4</a></li>
</ul>
</div>
https://jsfiddle.net/sameer_ngl/mjps7ufs/
See below:
The tabindex global attribute is an integer indicating if the element can take input focus (is focusable), if it should participate to sequential keyboard navigation, and if so, at what position. It can take several values:
a negative value means that the element should be focusable, but
should not be reachable via sequential keyboard navigation;
0 means that the element should be focusable and reachable via
sequential keyboard navigation, but its relative order is defined
by the platform convention;
a positive value means should be focusable and reachable via
sequential keyboard navigation; its relative order is defined by
the value of the attribute: the sequential follow the increasing
number of the tabindex. If several elements share the same
tabindex, their relative order follows their relative position in
the document.
An element with a 0 value, an invalid value, or no tabindex value should be placed after elements with a positive tabindex in the sequential keyboard navigation order.
Source: https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex

Twitter Bootstrap selected tab issue

I have tabs looking like that:
<li class="dropdown tab">
<a href="/Test" class="menu-url">
Test<i>Test here</i>
</a>
</li>
When the current tab is selected it is looking like that:
But I am getting an issue when I am hovering selected tab, so the issue looking like that:
Is there any way I can change <i> background-color to match href background-color when hovering an active tab?
You can set a transparent background
<li class="dropdown tab">
<a href="/Test" class="menu-url">
Test<i style="background:transparent">Test here</i>
</a>
</li>

Cause <DIV> contents to spread out?

Imagine I have a navigation bar in my page header, with a number of links. I'd like the links to spread out horizontally to fill the parent ; is there a way to do this using CSS which doesn't rely on me hard-coding based on the number of links? e.g if I add or remove a link I'd like it to still work.
I tried:
<div class="navBar">
<a class="navBtn" href="#" >Home</a>
<a class="navBtn" href="#" >Services</a>
<a class="navBtn" href="#" >About us</a>
<a class="navBtn" href="#" >Blog</a>
<a class="navBtn" href="#" >Contact</a>
</div>
div.navBar
{
text-align:justify;
}
a.navBtn
{
font-style:italic;
}
But this just left-aligns the text. I know I could use a table but just to show I can, I'm trying to do it 'properly'. Or, is this a case where a table is 'proper'?
Text-align: justified;
Another option is to create a table with width: 100% around your nav bar and have each nav item be in a td
you could even set the width, in percentage, of each td